ChemCAD 5 services to visual basic applications: User Manual, страница 5

Function RxnRate001(ByVal Temp As Double, ByVal Pres As Double,

    ByVal Rpm As Double, ByRef Conc() As Double, ByRef KPar() As Single,

    ByVal ChemCADEntry As Object) As Double


    RxnRate001 = …

End Function

These codes are first generated by CHEMCAD 5. After imported into Excel workbook, user can make changes as needed. Information on liquid (include solid) or vapor phases can be accessed through ChemCADEntry object handle. The interface for this object handle is described in the previous section on Excel Unit.

specification sheets

From unit operation data in CHEMCAD 5, user can generate specification sheet in Excel. Following the instructions discussed in this section, user will be able to generate satisfactory specification sheets.

First locate a file named “specsht.xls” under your work directory or your program directory. When opening up the Excel workbook, user will find several specification sheets for various unit operations. If modifications or additions to the available sheets are necessary, make a copy of the file to your job directory or work directory before making changes. When any changes are made to any of the available sheets, user should also examine the corresponding VBA macro for any subsequent changes.

Three  elements are involved in generating a specification sheet. The first is a worksheet named and formatted to produce the layout of the specification sheet. The second is a VBA subroutine that retrieves data from CHEMCAD 5 and places the data on the worksheet. The third is the identification of the subtype and the name of the VBA subroutine in existing macro named “GetEquipmentSubTypes”. When a new specification sheet for a subtype is required, user need to format a new worksheet, add a string to represent the subtype in macro named “GetEquipmentSubTypes”, identify the a new macro for the subtype, and program a VBA subroutine to fill in data on the new worksheet.

The file name of the workbook has to be “specsht.xls”. It may be stored in job directory, work directory or program directory, and the search is in this order. The macro containing all the available subtypes has to be “GetEquipmentSubTypes”. However, user can freely name worksheets that present the specifications, and the macros for filling in data from CHEMCAD 5 to these worksheets. For each unit operation, user can have up to 40 subtypes of equipment. The length of subtype names and their macros should be less than 64 characters.

When the specification sheets are prepared in the Excel workbook, user can start CHEMCAD 5 select Tools à Spec Sheet, and pick a unit operation. All the available subtypes for the unit will be displayed. The list of the subtypes is retrieved from VBA macro “GetEquipmentSubTypes”. After user selected a subtype, CHEMCAD 5 activates the macro for the subtype to complete the specification sheet, and display the corresponding Excel worksheet.


This section describes the interfaces from which the topology of current flowsheet can be established. Two interfaces, ICurUnitOp and IFlowsheet, are discussed.

Description      ICurUnitOp interface gives the counts and IDs of the inlets and outlets of the current Excel Unit. User can also get the unit ID of the current Excel Unit, loop count and maximum number of runs. This interface can only be used in the case of an Excel Unit.


dispinterface ICurUnitOp



short GetNoOfInlets();

short GetInletIDs(VARIANT inletIDs);

short GetNoOfOutlets();

short GetOutletIDs(VARIANT outletIDs);

short GetCurUnitOpID();

short GetLoopCount();

short GetLoopLimit(); 

short GetReactorLiquidPhase(VARIANT compLbmol);

short GetReactorVaporPhase(VARIANT compLbmol);

short GetRerunFlowsheetFlag();

short SetRerunFlowsheetFlag(short rerunIfOne);


Methods          The following two methods give the count and the IDs of inlets. The ID array need to be defined in VBA macro before calling GetInletIDs with lower bound at one and upper bound at no less than the inlet count.