Retrieving Aspen Plus Error Messages with Visual Basic

Download as pdf : 
Products: Aspen Plus 
Last Updated: 03-Nov-2020
Versions: 
Article ID: 000056985
Primary Subject: 
Converted from "102459_Default.txt"

Applicable Version(s)

Aspen Plus 10


Problem Statement

How can I retrieve Aspen Plus Error Messages with Visual Basic?


Solution

Aspen Plus error messages are stored in a folder called PER_ERROR below the objects which they reference. For example, the messages for the overall simulation are stored as a PER_ERROR collection under Results Summary/Run Status. The PER_ERROR message collection for convergence blocks can be found under the Output section of the actual convergence block.

The attached example contains a general subroutine (CheckForErrors) that will retrieve these messages. In this example, the error messages are retrieved from a convergence block that was assigned to converge a design specification. This example was written for Aspen Plus 10.1 and Excel97.


  1. Define a local object variable for CheckForErrors. The messages for this object will be retrieved if this object has a status equal to error.

Dim lo_ErrFolder As IHNode

  1. Define a local collection describing where the error messages are located. The route to the PER_ERROR object is slightly different for different objects.

Dim lc_ErrMessF As IHNodeCol

  1. Define string variables to hold status and error messages

Dim ls_Error As String
Dim ls_Message As String



  1. Set local object to Convergence Block of interest

Set lo_ErrFolder = go_Simulation.Tree.Data.Convergence.Convergence.Elements("C-1")

  1. Set local collection defining location of error messages

Set lc_ErrMessF = lo_ErrFolder.Output.PER_ERROR.Elements

  1. Call routine to gather error messages from object

Call CheckForErrors(lo_ErrFolder, lc_ErrMessF, _



ls_Error, _
ls_Message)


  1. Display error status and messages in Excel. Messages will be written to Excel Text box named Errors.

Range("Status").Value = ls_Error

Errors.Text = ls_Message

KeyWords

VB, VBA, error





Attachments
Filename Date Added
VBErrorMsg.xls 18-Jan-2017
ActiveX-ds-ws.bkp 18-Jan-2017