STEM help / Editor skills

4.13.2 Managing external links

If you make an external reference in a formula in a model, STEM will retrieve the specified data as soon as you enter the formula. Whenever you open the model in the Editor, or run the model, STEM will check the external file to see if it has been modified since you last retrieved the data. If so, STEM will ask you whether you want to update the links to that external file.

Updating external links

If you modify and save an external file while the model is open in the Editor, you can retrieve the latest data:

  1. Select Links… from the File menu on the main Editor window. The External Links dialog is displayed.
  2. Select the particular file from the list of links.
  3. Select the Update button to retrieve the latest data. Any dependent formulae will be re-calculated automatically.

Note: STEM does not update links automatically when an external file is modified or saved, and will not retrieve unsaved changes to a spreadsheet which has been modified in Excel.

Opening an external file

If you have made external references to another STEM model or to any other file, you can open that model or file directly from the External Links dialog:

  1. Select Links… from the File menu on the main Editor window. The External Links dialog is displayed.
  2. Select the file from the list of links.
  3. Select the Open button. If you have selected a model to open, this will be loaded into the Editor. If you have selected another file, and an associated application can be found (e.g., Microsoft Excel for an Excel workbook), this application will be started (if it is not already running) and the specified file will be loaded.

Storing external links with relative paths

When you first create an external reference, STEM will store the full path of the external file, even if you just type the filename of another model or spreadsheet in the same directory as your model. If you subsequently copy or move your model to a different directory, STEM will still look in the original directory for the external file. This absolute path is well suited to external files common to several modelling projects in different directories.

However, if you plan to copy or move your model, together with the accompanying external file, to another directory, perhaps on a different machine, you may find it convenient to save a relative path for the external file:

  1. Select Links… from the File menu on the main Editor window. The External Links dialog is displayed.
  2. Select the particular file from the list of links.
  3. Select the Change… button. The Define External Link dialog is displayed.
  4. Select the Relative Path check box to make the path relative and click OK or press <Enter>.

Managing external links

Now STEM will look for the external file in the new directory, when you copy or move the model.

STEM can store a relative path to an external file anywhere on the same drive (e.g., C:) as the model itself. If the file is in a sub-directory of the model directory, the path will be relative to the model directory; otherwise it will specify the full path, less the drive. For example, consider a model, C:\MODELS\SIMPLE.DTL, with external files C:\LIBRARY\COSTS.XLSX and C:\MODELS\DEMAND\GROWTH.XLSX. As relative paths, these would be stored as \LIBRARY\COSTS.XLSX and DEMAND\GROWTH.XLSX respectively, allowing you to copy a set of files to a different machine or drive with the same overall directory structure.

Note: STEM cannot store a relative path to an external file on another drive, or if the model has not yet been saved.

Changing external links

STEM will not be able to locate an external file:

  • if you rename, move or delete the external file, or
  • if you copy a model to a different directory or machine without copying the necessary external files (as above).

In order to rectify this problem, or if you specifically want to use a different file:

  1. Select Links… from the File menu on the main Editor window. The External Links dialog is displayed.
  2. Select the particular file from the list of links.
  3. Select the Change… button to display the Define External Link dialog.
  4. Enter a new filename, or select the Browse… button to display the Select External File dialog, a standard Windows file-selection dialog, where you can browse to select the required file.
  5. Click OK to change all references to the previous external file to the newly selected file. The list of Links in the External Links dialog is updated and the appropriate data is retrieved from the new file.
 

© Implied Logic Limited