Hysys Excel Automation Training

Tuesday, October 1, 2013

How to Use Hysys Splitter in VBA

Hi there,

This post is requested by Mayembe. He asked me to post a VBA code in Excel to access Hysys splitter.

Here is the VBA example


' VBA code starts here
Option Explicit
Public hyApp As HYSYS.Application
Public simCase As SimulationCase
Public tee1 As TeeOp

Public Sub StartHYSYS()
Dim filename As String
Dim ratio As Variant

    Set hyApp = CreateObject("HYSYS.Application")
    hyApp.Visible = True
    Set simCase = hyApp.ActiveDocument
    If simCase Is Nothing Then
        filename = Worksheets("Sheet1").Range("c4")
        If filename <> "False" And simCase Is Nothing Then
            Set simCase = GetObject(filename, "HYSYS.SimulationCase")
            simCase.Visible = True
        End If
    End If

Set tee1 = simCase.Flowsheet.Operations("teeop").Item("tee-101")
ratio = tee1.SplitsValue
ratio(0) = Worksheets("Sheet1").Range("c5").Value
ratio(1) = Worksheets("Sheet1").Range("c6").Value

tee1.Splits.SetValues ratio, ""

End Sub
'this is the end of VBA code


Just for your note, "TEEOP" is a operation code name for "TEE" or splitter in Hysys.

And here is the excel interface. I use previous example of hysys file to develop our model. If you forget about our previous hysys model, check previous example

Grab hysys file  and excel file from google drive

That's it. Hysys splitter is in your hand.

Let me know that you have comment or request. We'll see what I can do. I hope.



  1. Hi Alex,
    It has been a while since I last visited your blog.
    Thank you for posting the code for the splitter.

  2. Hi Alex,
    can u help me to read the content of Notes tab present in any material stream or operation through vba excel.
    I tried a lot but not able to find any help on this topic.

  3. This comment has been removed by the author.

  4. Hi, great blog.

    There is any way to get a VB code for each equipment in hysys, to make custom operations? I want to make a separator, but including the code to size a vertical vessel with semielliptical or semicircle heads.


  5. Hi
    Thank you for your posting
    i have one question.
    Can i change the binary parameter using VBA?
    when i choose the "PRSV" as a property PKG.
    then input kij and kji for calculation of binary interaction.
    kij and kji are constant but, in paper, there are function of temperature
    for example, kij = cij + dij*T(K)
    So, i want input the binary parameter as function of temperature.
    How can i do?
    pleases let me know.

  6. Hi, thank you for your code. Actually I tried to implement it in order to send data from VBA to Hysys to change the ratio of the splitter from the excel sheet, but unfortunately it's not working. It doesn't accept this syntax : tee1.Splits.SetValues ratio, "" Can I write it differently ?? Thank you very much