Useful information for getting started to use the COM technology, and setting up your project using Excel and the Visual Basic Editor (VB Editor) is provided in this section. Visual Basic for Applications (VBA) is Microsoft’s common scripting language that facilitates the interoperability of various applications. Familiarity with VBA is important for taking full advantage of the Pro-Designer COM Server, however this manual provides the basic examples one can follow to carry out simple tasks.
For the following procedure we will be using the Excel spreadsheet example ComEx1.xls along with the ProDesigner simulation case ComEx1.spf. This excel spreadsheet contains many useful scripts for using the COM functions. It can be also used for a parametric study as described in the Sensitivity Analysis Example. Before you start using this example you must perform the following tasks:
1. Open the ComEx1.xls file with MS Excel.
2. Choose “Enable Macros” when opening excel file or visit the Macro Security settings and enable all macros (MS Excel 2007-2013).
3. Specify the path and name of the Pro-Designer file in designated cells (C:\Designer\ComEx1.spf).
4. From the Excel main menu choose Tools/Macros/Visual Basic Editor or click on the Visual Basic Editor button located on the Visual Basic toolbar. MS Excel 2007-2013 users may select the Developer tab and click on the Visual Basic icon button. (note: if the Developer tab is not showing in the Ribbon, click on the Office Button on the top left corner of Excel, select Excel Options, and check “Display the Developer Tab in the Ribbon” checkbox.) This brings up the Visual Basic Editor interface which looks like the picture bellow:
5. From the VB Editor main menu select Tools / References, which brings up the following dialog:
6. Scroll down in the list until you find the SuperPro Designer reference library (This is the Designer Type Library exposed by the Pro-Designer OLE Server). Check the library to be included in your references. The location of the library is shown in the lower part of the window as shown in the following dialog. You may click on browse to find the library (“Designer.tlb”) in case the location shown below is not pointing to the exact path were SuperPro Designer is installed.:
|
Make that the location of the library corresponds to the latest version of the software installed. If this is not the case you should close MS Excel or any other MS Office application, run the latest version of Pro-Designer software first, and then open MS Excel to select and include the correct Designer Type Library. When running the latest version of Pro-Designer, Wιndows registry will get updated with the correct location of the library. It is highly recommended to first uninstall any older versions of Pro-Designer that may exist on your system. |
7. By now the Designer library should be included in your project. You can view the libraries in the project by displaying the VBA Object Browser (press F2 or click on the icon on the standard toolbar, or select View / Object Browser from the VBE main menu).
8. You can now save your Excel wotksheet.Next time you open the file, you do not have to repeat these steps. Just verify that the Designer library is added to your Excel references by checking the object browser.