Using the PowerSHAPE OLE ServerThis page shows what interfaces are available via the PowerSHAPE OLE server.
Connecting to an existing PowerSHAPE session
This method will create the object 'pshape', which is connected to an existing PowerSHAPE session. Set pshape = Getobject(,"PowerSHAPE.Application")
With this method, when you quit the VB application, the PowerSHAPE session remains open.
Displaying the PowerSHAPE window
You can show or hide the PowerSHAPE window, using the server interface:
To show the PowerSHAPE window:
To hide the PowerSHAPE window: pshape.Visible = True
pshape.Visible = False
Controlling the PowerSHAPE window
You can minimise/maximise/normalised and bring to foreground the PowerSHAPE window, using the server interface:
To nomalise the PowerSHAPE window:
pshape.windowstate = 1
To maximise the PowerSHAPE window:
pshape.windowstate = 2
To mimimise the PowerSHAPE window:
pshape.windowstate = 4
To bring the PowerSHAPE window to foreground:
pshape.windowstate = 8
Getting the current PowerSHAPE version
This can be used to check if a connection is made to PowerSHAPE. If the returned version is 0, or an error is generated, then no connection exists.
To extract the version number use the server interface:
Debug.Print pshape.Version
Sending commands to PowerSHAPE
Similar to a user typing in the command window, or using macro commands, you can send a command to PowerSHAPE with the server interface:
Where 'command_string' is a string containing the command pshape.Execute command_string, error_flag
And 'error_flag' is a LONG variable, and is an error flag which is only set if there is an internal error within PowerSHAPE. It is required to use the command, but its value can normally be ignored.
pshape.Execute "SELECT CLEARLIST", error e.g.
Getting values from PowerSHAPE
Anything you can print the value of in PowerSHAPE, you can extract the value via the OLE server. The server will return a VARIANT variable, which means the result can be either a number, and string, or even a vector (or array of numbers).
To use the print method, the syntax is:
When value_string is a string containing the object you require the information on Dim V as Variant V = pshape.Print (value_string)
So for example, to extract the number of selected entities, you could use:
Checking if PowerSHAPE is busy V = pshape.Print ("selection.number")
The BUSY property of the PowerSHAPE server lets you know if PowerSHAPE is working. You can use this to check if PowerSHAPE is busy before sending certain commands. The BUSY property will be either TRUE or FALSE.
For example, you could do the check:
Showing/Hiding Forms when Executing Commands If pshape.Busy = False then Pshape.execute etc.
End if
To access certain functions, such as changing a surface's name, you need to raise the Surface Modify form. When using the OLE server however, you normally do not want to see the form, only to access the functions within it. By default, the forms are hidden, but you can control this via the ShowForms property.
So to show forms when sending OLE commands, you can use:
And to hide forms when sending OLE commands (this is the default), you can use: Pshape.ShowForms = True
Quiting PowerSHAPE Pshape.ShowForms = False
To quit PowerSHAPE via the interface, use the command:
pshape.exit