Using the PowerMILL OLE ServerThis page shows what interfaces are available via the PowerMILL OLE server.
Creating a new PowerMILL object
This will create a new PowerMILL session, linked to the object 'pmill'. Set pmill = Createobject ("PMill.Document")
With this method, when you quit the VB application, because the 'pmill' object is destroyed, PowerMILL will close down.
Connecting to an existing PowerMILL Session
This method will create the object 'pmill', which is connected to an existing PowerMILL session. Set pmill = Getobject(,"Pmill.Document")
With this method, when you quit the VB application, the PowerMILL session remains open.
Displaying the PowerMILL Window
You can show or hide the PowerMILL window, using the server interface:
To show the PowerMILL window:
To hide the PowerMILL window: pmill.Visible = True
pmill.Visible = False
Controlling the PowerMILL Window
You can minimise/maximise/normalised and bring to foreground the PowerMILL window, using the server interface:
To nomalise the PowerMILL window:
pmill.windowstate = 1
To maximise the PowerMILL window:
pmill..windowstate = 2
To mimimise the PowerMILL window:
pmill.windowstate = 4
To bring the PowerMILL window to foreground:
pmill.windowstate = 8
Getting the current PowerMILL version
This can be used to check if a connection is made to PowerMILL. 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 pmill.Version
Sending commands to PowerMILL
Similar to a user typing in the command window, you can send a command to PowerMILL with the server interface:
Where 'command' is a string containing the command pmill.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 PowerMILL. It is required to use the command, but its value can normally be ignored.
pmill.Execute "DRAW ALL", error e.g.
You can also send commands to PowerMILL, and extract the resulting message from the command window, using the interface:
pmill.ExecuteEx command_string, error_flag, messages_string
Where 'command' and 'error_flag' are similar to using the 'Execute' method,
And 'messages_string' is a string variable, in which the command window output will be placed.
e.g.
pmill.ExecuteEx "SIZE COMPONENTS",error, size
The string variable 'size' will contain the command window message.
Quiting PowerMILL
To quit PowerMILL via the interface, use the command:
pmill.exit