Creation Date: 26-Dec-2001 09:04AM
10.2 and above
VBA Example to take control (Open/Run/Close/Reinit) of an Aspen Plus simulation via ActiveX automation.
The attached Excel file contains a Visual Basic for Application (VBA) code that will:
This example could be used as a starting point for building a VBA interface to retrieve specific Aspen Plus results.
To run this example, copy the included Excel file onto your hard-drive and open it. This Excel VBA code is setup to work with Aspen Plus 10.2. If you want to use it with other versions of Aspen Plus, proceed as follows:
Code Description
The VBA code contains a global variable that will hold the reference to the Aspen Plus ActiveX object: go_Simulation. This object is declared as an HappLS object.
Set go_Simulation = Getobject(lbFileName) where lvFileName contains the full path to the simulation file to be opened.
The Graphical User Interface (GUI) is then made visible or not, depending on the value of the chk_IsVisble checkbox. The code to make the GUI visible/invisible, depending on the checkbox state, is:
go_Simulation.Visible = chk_IsVisible.Value
go_Simulation.Engine.Run2
The Run2 method has an optional argument (boolean type) that will make the run running synchronously or asynchronously (see Tech Tip # 102859 and # 104805 for more details).
go_Simulation.Engine.Reinit(IAP_REINIT_SIMULATION)
The argument passed to the Reinit method defines what part of the simulation should be reinitialized. Other valid arguments are:
IAP_REINIT_BLOCKto reinitialize a blockIAP_REINIT_CONVERGENCEto reinitialize a convergence blockIAP_REINIT_SIMULATIONto reinitialize the entire simulationIAP_REINIT_STREAMto reinitialize a stream
Technical tip 102365 provides more details about the Reinit method.
go_Simulation.Visible = False Set go_Simulation = Nothing See cmd_CloseSimulation_Click subroutine.
See Chapter 38 of the Aspen Plus User Guide for further details about the Aspen Plus ActiveX Automation Server.
ActiveX,COM,Automation,Visual Basic for Applications (VBA), Reinit