Beside access to the Excel workbook built in to INOSIM (see tip Benefit From Your Excel Knowledge While Working With INOSIM), the Visual Basic editor even allows applying external Excel files: Existing Excel files may be opened or new workbooks may be created.


  1. Enable the Microsoft Excel Object Library in the INOSIM Basic editor (menu Tools/References):

    Enabling the Microsoft Excel Object Library in Visual Basic

  2. Create a new object variable (e. g., Excel) specified as global Public variable:

    Specifying object variable

  3. In your simulation´s initialization, assign the Excel application to that object variable by using the CreateObject  function:

    Assigning the Excel application

Opening an existing external Excel workbook

Now, by the object variable of the same name, you have access to MS Excel. To open an already existing Excel workbook, you can use the Open method. Add the file path and name of the workbook as argument then.

Opening the Excel workbook

The Excel workbook stored in variable wbk now can be read and edited.

In the following example, the values num_Batches_A, num_Batches_B, and num_Batches_C from workbook Number of Batches of the external workbook InputData are read:

Reading the values

When it is no longer needed, close the workbook by the Close method and save your changes with Save, if necessary.

Tip: If within the code you do not wish to determine the file path of the Excel workbook, you can initiate manual selection at simulation start with the help of the GetFilePath function.

Manual workbook selection

Creating a new Excel workbook

If you wish to create a new Excel workbook, for example, to store the results of paticular simulation runs separately, you can use the Add method. For that purpose, first add a new Excel workbook, then add a new worksheet to it.

Creating a new workbook with a new worksheet

The worksheet may be edited as usual then. In the present example, the contents of the tanks Storage A, Storage B, and Storage C are passed to worksheet  Results 1. After all results have been passed, the new worksheet has to be saved. To do so, use the SaveAs method. After saving, close the workbook.

Passing unit parameters to an Excel worksheet

Download the Example Model (for registered INOSIM Users only)

Download the Example Excel input file (for registered INOSIM Users only)

Do you still have questions or want more information? Then please contact us!

More tipps & tricks here ...

© 2020 INOSIM Software GmbH