
Automation 2-11
2-11
For application objects or document objects the codes are shown
below:
In the example below, hyCase is declared as type object so it is
using late binding. The hyCase variable is connected to a HYSYS
case by using the GetObject function and the Set keyword. The
second argument in the GetObject function is the starting
object.
The second example is identical to the first except that the
object variable hyCase is declared using the actual object name
as it appears in the type library. This assumes that a reference
to the type library has already been set.
The third example uses early binding in the object declaration.
The CreateObject command is used to bring up an instance of
HYSYS. The starting object here is the HYSYS.Application object
since a case is not initially being opened. The SimulationCases
object is accessed through the Application object and the Open
method of SimulationCases is used to bring up a specific HYSYS
case. The hyCase object is set to the active case through the
Example: CreateObject and GetObject
Set applicationobj = CreateObject(“HYSYS.Application”)
or
Set applicationobj = GetObject(, “PROGRAM.Application”)
Set documentobj = GetObject(“c:\filepath”, “PROGRAM.Document”)
Example 1: Starting a HYSYS case through Automation
Dim hyCase As Object
Set hyCase = GetObject(“c:\samples\c-2.hsc”, “HYSYS.SimulationCase”)
Example 2: Starting a HYSYS case through Automation
Dim hyCase As SimulationCase
Set hyCase = GetObject(“c:\samples\c-2.hsc”, “HYSYS.SimulationCase”)
Komentáře k této Příručce