Using the PowerMILL OLE Server

This page shows what interfaces are available via the PowerMILL OLE server.

Back to main index
 
 

Creating a new PowerMILL object

Set pmill = Createobject ("PMill.Document")

This will create a new PowerMILL session, linked to the object 'pmill'.

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

Set pmill = Getobject(,"Pmill.Document")

This method will create the object 'pmill', which is connected to an existing PowerMILL session.

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:

pmill.Visible = True

To hide the PowerMILL window:

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:

pmill.Execute command_string, error_flag

Where 'command' is a string containing the command

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.

e.g.

pmill.Execute "DRAW ALL", error
 
 

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