You are on page 1of 5

HYSYS Stream Reporter Utility version 1.

1, User Guide
James Martin, AEA Technology, Hyprotech, UK Technical Services
26th February 2001
1 Introduction
The HYSYS Stream Reporter (HSR) utility allows material stream conditions, properties and
compositions to be easily reported onto a Microsoft Excel spreadsheet. It also enables streams
in different cases to be conveniently compared.
HSR can report properties from the following phases: Overall, Vapour, Light and Heavy
(/Aqueous) Liquid, Combined Liquid, and Solid. It also allows stream user variables to be
reported.
HSR takes the form of an Excel spreadsheet file with embedded Visual Basic for Applications
(VBA) code that demonstrates how HYSYS can be accessed programmatically. The VB
source code is freely accessible and users are encouraged to learn from it and adapt it to their
own needs.
HSR has been fully tested in versions 2.1.1, 2.2, 2.3 and 2.4 of HYSYS but should also work
with previous and future versions. (See section 7 for information when using HSR with
HYSYS versions other than 2.2). HSR was written using, and fully tested in, Microsoft Excel
97. It’s use in Excel 2000 has not been fully tested at the time of writing.
1.1 Changes for version 1.0.1
Combined liquid phase properties now correctly reported. Version 1.0 had a bug where if a
combined liquid phase property was selected above a light or heavy liquid property then every
time a light liquid property was reported it actually corresponded to the combined liquid.
(Ideal) Liquid Volume flow property for individual phases now reported correctly, previously
this reported Std Liquid Vol Flow.
Fixed minor bugs concerning deleting worksheets, unnamed (sub) flow sheets, and clarified
some error messages.
1.2 Changes for version 1.0.2
Fixed a bug which meant that problems accessing a local/network drive prevented the
Cases/Flowsheets/Streams lists being updated.
1.3 Changes for version 1.1
When switching between HYSYS versions, now checks to see if stored units match units
available in HYSYS, and updates them if not.
2 Installation
No installation is required, simply copy the Excel spreadsheet file HSR.xls to a convenient
location and double click it to open it in Excel.
3 Important Note
This Automation application has been created by Hyprotech Technical Support as an example
of what can be achieved through the object architecture of HYSYS. The application is
provided for academic purposes only and as such is not part of Hyprotech's normal QA

HYSYS Stream Reporter Utility version 1.1, User Guide 1 of 5


procedures. We strongly encourage users to check results carefully and use the facility
accordingly. Please report any problems encountered through the normal support channel at
support@hyprotech.com
4 Usage – Producing Stream Tables
The HSR spreadsheet is initially organised into two separate worksheets. The Setup
worksheet is where the streams and properties to be reported are specified. The Comparison
sheet is where settings for the case comparison tool are specified. When output tables are
produced they are added as separate pages in the main workbook, they can then be copied or
moved into other spreadsheet files. (See section 4.1)
Using HSR to produce an output table is a simple four-stage process.
1. Choose streams to report
2. Choose an output location for the table
3. Choose properties to output
4. Write the table
Each step is described in detail below.
1. Choose streams to report
The three list boxes (Cases, Flowsheets, and Streams) allow any stream in a currently open
case within HYSYS to be selected. To report properties from a stream: select it in the Streams
box, then press the Use Selected button. Streams that will be reported are shown in the rows
underneath. The Use All button allows all the streams in a flowsheet to be used.
If the list boxes are empty then press the Update Lists button to link to the currently open
copy of HYSYS and update them. N.B. Changes made in HYSYS (e.g. adding streams,
opening cases etc…) are not reflected until the Update Lists button is pressed.
The Sorting radio buttons change the order in which the streams are displayed in the Streams
box, and hence the order they appear in the final stream table when they are selected.
To remove a stream from the list of streams for output, simply delete the values from the row
and move the streams in the rows beneath up a row.
2. Choose an output location for the table
Select an output worksheet in the Output Worksheet list box.
Stream tables can only be reported onto worksheets specially prepared by the HSR utility. To
add a new output worksheet: press the Add Sheet button. To delete the selected output
worksheet: press the Delete Sheet button. If output worksheets are manually renamed or
deleted, the Output Worksheet list box will update automatically.
The Advanced … button (See section 4.1) allows output worksheets to be copied to different
Excel files whilst maintaining the ability to refresh the information, and to be converted into
normal worksheets.
3. Choose properties to output
Almost all of the stream properties available within HYSYS can be reported. Properties are
added by making selections from the in-cell drop down lists, this is a three-stage process.
Choose a phase in the left most column. Phases available are: Overall, Vapour, Light Liquid,
Heavy Liquid (usually aqueous), Combined Liquid, and Solid.

HYSYS Stream Reporter Utility version 1.1, User Guide 2 of 5


Choose a property of the phase in the middle column. Properties available depend on which
phase is chosen.
Choose a unit in which to display the property value. If Cur. HYSYS Unit is chosen the unit
currently set in HYSYS will be used. [This only works in HYSYS 2.2 or greater, for versions
before this the values are displayed in the appropriate HYSYS internal unit – i.e. the unit that
HYSYS does it’s internal calculations in.]
Alternatively the value of a user variable can be reported if User Variable is selected in the
phase drop down. Enter the user variable Tag (not Name) in the Property column. Initially
user variables can only be reported in the current HYSYS units (or internal units for HYSYS
versions prior to 2.2), although if desired this can be changed once the output table has been
produced.
To remove a property from the list, simply delete the values from the row and move the
properties in the rows beneath up a row.
Once a set of properties has been selected it can be saved for later use by pressing the Save
Current button and entering a name for the property set. To use a previously saved property
set: select it in the list and press the Use button. A number of predefined property sets are
supplied with the utility. The HYSIM stream summary set allows a similar report to that
generated by HYSIM to be produced.
Property sets can be deleted by pressing the Delete button, and the order in which they appear
in the list box can be adjusted by pressing Sort List …
4. Write the table
Once streams, properties and an output location have been selected the output table can be
generated by pressing the Write Table button.
Stream tables, can be updated by pressing the Update Stream Table button. If required the
properties and units can be adjusted by choosing from the drop down lists.
4.1 Output Worksheets – Advanced …
Pressing the Advanced … button, next to the Output Worksheet list box, brings up the Output
Worksheets ... Advanced window.
This gives access to two functions:
 Copy worksheet, maintaining ability to refresh information
This allows an output worksheet to be copied within or between Excel workbooks whilst
maintaining the ability to update the data from HYSYS by pressing the Update Stream Table
button.
To use this function click it’s radio button, choose the worksheet to be copied, and then the
target workbook and press the Copy button.
Note that when you copy an output worksheet to a new Excel workbook, each time this
workbook is loaded HSR.xls will also be loaded automatically to allow the update stream
table functionality to work. To stop this from happening the output worksheet must be
converted to a normal Excel worksheet…
 Convert worksheet to a normal Excel worksheet
By doing this the output worksheet will lose the ability to choose new properties, change units
and update from HYSYS.

HYSYS Stream Reporter Utility version 1.1, User Guide 3 of 5


To use this function click it’s radio button, choose the worksheet to be converted, and then
press the Convert button. An Excel dialogue box appears asking whether it is OK to delete
the selected sheet(s). Press OK.
[This occurs because in the conversion process HSR copies the values from the output
worksheet onto a new sheet and then deletes the output worksheet – it is not possible to
suppress the Excel confirmation message when programming in VBA.]
5 Usage – Case Comparison Tool
The case comparison tool is configured from the Comparison worksheet. Using the case
comparison tool is a three stage process.
1. Match reference and comparison streams
2. Choose an output location for the table
3. Write the comparison table
Each step is described in detail below.
1. Match reference and comparison streams
The first step is to generate two stream tables on different output worksheets for the cases (or
groups of cases) that are to be compared. [For example these may be the same case before
and after some modification has been made.]
Select one of these worksheets to be the Reference sheet and one the Comparison sheet.
Streams on the Comparison sheet are compared to those on the Reference sheet.
Press the Analyse streams on these worksheets button. This will generate a list of all the
streams on the reference sheet and the comparison sheet. HSR automatically tries to match up
like named streams.
If required the comparison stream that is compared to each reference stream can be changed
by choosing from the in-cell drop down lists.
The reference and comparison sheets must list the same properties otherwise the results
produced will not make sense.
2. Choose an output location for the table
Select an output worksheet in the Comparison Output Worksheet list box.
Similarly to stream tables, comparison tables can only be reported onto worksheets specially
prepared by the HSR utility. To add a new output worksheet: press the Add Sheet button. To
delete the selected output worksheet: press the Delete Sheet button.
3. Write the comparison table
Finally press the Write Comparison Table button to generate a comparison table. HSR
generates a table with Excel formulae to link to the reference and comparison sheet values, so
when these are updated the comparison table will be automatically updated.
6 Authors Note
All the VBA source code is freely accessible [Tools … Macro … Visual Basic Editor] and not
password protected. It is fully documented and can be used as a basis on which to build your
own VBA programs that link to HYSYS via OLE. I do not however claim that the code is
perfect, or even the best way of doing things. If you find any bugs in the code, or think of any

HYSYS Stream Reporter Utility version 1.1, User Guide 4 of 5


improvements please report them to support so the utility can be improved for the benefit of
all users.
7 Troubleshooting / Using different HYSYS versions
When linking Excel to HYSYS, the HYSYS type library must be correctly “referenced” to
allow Excel to access HYSYS’ functions. As supplied the HSR spreadsheet is set up with a
link to HYSYS version 2.2. If a different version of HYSYS is in use then HSR may report
errors like:
“Method or Data Member not found,” “Type Mismatch,” or RPC errors. These can often be
solved by re-referencing the HYSYS type library. The procedure to do this is as follows:
 Close HSR and Excel if it is open
 Open and close the version of Hysys that is to be used
 Go to the VBA editor. (Tools … Macro … Visual Basic Editor, or press Alt + F11)
 In the VBA editor go to Tools … References
 If “HYSYS #.# Type Library” (where #.# is the version of HYSYS being used) is checked
uncheck it and press OK, then go to Tools … References again
 Find “HYSYS #.# Type Library” in the list, check it, press OK and close the VBA editor.
Save HSR.xls, close Excel and reopen HSR.xls

HYSYS Stream Reporter Utility version 1.1, User Guide 5 of 5