Jump to content



Featured Articles

Check out the latest featured articles.

File Library

Check out the latest downloads available in the File Library.

New Article

Product Viscosity vs. Shear

Featured File

Vertical Tank Selection

New Blog Entry

Low Flow in Pipes- posted in Ankur's blog

How To Link Hysys To Excel


This topic has been archived. This means that you cannot reply to this topic.
26 replies to this topic
Share this topic:
| More

#1 alphadian

alphadian

    Brand New Member

  • Members
  • 3 posts

Posted 12 April 2012 - 04:29 AM

Hy everyone.

i want to Link my hysys simulation to excel, so i can work in excel too. can you help me, please?? what should i do?
thanks... :)

#2 Technical Bard

Technical Bard

    Gold Member

  • ChE Plus Subscriber
  • 407 posts

Posted 12 April 2012 - 09:52 PM

The Aspen Simulation Workbook, which you need to license separately, is one way. Alternatively, you can write VBA code underneath Excel to connect to the HYSYS COM object and interact with it that way. The HYSYS type library (hysys.tlb) is relatively well documented and Aspen has some training material on how to do this.

#3 Alexsandres

Alexsandres

    Junior Member

  • Members
  • 27 posts

Posted 15 May 2012 - 05:09 AM

alphadian,

As Bard said, i use VBA code to link excel and hysys. I posted examples how to link excel and hysys several months ago, hope this link helps.
http://hysyssimulations.blogspot.com

Alex

#4 sacarove

sacarove

    Gold Member

  • Members
  • 54 posts

Posted 06 November 2012 - 08:25 AM

Hi Alex,

Thank you for sharing that. I want to export the molar fraction components to excel. Because it is an array I am trying to use "For" loop but I am getting error when I run it.
Can you please assist on that from your VBA code?

Thanks

Sacarove

#5 Bobby Strain

Bobby Strain

    Gold Member

  • Members
  • 3,529 posts

Posted 06 November 2012 - 02:03 PM

You only need to set up array when importing from Excel into HYSYS. Get the workdump project from the support site and you will find all the code you need. There is also a project called stream reporter. Lots of code.

Bobby

#6 Marry Sheikh

Marry Sheikh

    Brand New Member

  • Members
  • 1 posts

Posted 08 November 2012 - 05:13 AM

Hi Alphadian,
There is no such a need for VBA code or its programming for creating a link between excel and hysys. Just download a file named as "Workbook Dump" and use it while remaining the hysys file open. I think it will be quite easy for you.Thanks

#7 Joyce J. Ruiz

Joyce J. Ruiz

    Brand New Member

  • Members
  • 2 posts

Posted 15 November 2012 - 02:38 PM

What is VBA Code?

#8 Dacs

Dacs

    Gold Member

  • Members
  • 393 posts

Posted 15 November 2012 - 07:46 PM

What is VBA Code?

Something that you rely heavily on when linking Hysys with Excel, or making Excel much more functional for that matter.

VBA stands for Visual Basic for Applications, basically an implementation of Visual Basic (which is a programming language) for your Windows application.

#9 Bobby Strain

Bobby Strain

    Gold Member

  • Members
  • 3,529 posts

Posted 15 November 2012 - 10:02 PM

And it is available in Microsoft EXCEL. And, you can use VB, too, which is a free Microsoft product.

Bobby

#10 Padmakar Katre

Padmakar Katre

    Gold Member

  • ChE Plus Subscriber
  • 992 posts

Posted 12 December 2012 - 02:19 AM

Hi,
The link might be useful for few of you.

http://www.cheresour...xcel-converter/





#11 Alexsandres

Alexsandres

    Junior Member

  • Members
  • 27 posts

Posted 28 February 2013 - 01:22 AM

savarove, you may use this code to obtain molar composition


===================================================

Dim ambildata As ProcessStream, item as integer


 

Set ambildata = simCase.Flowsheet.MaterialStreams.ITEM(“stream1”)


 

For ITEM = 1 To 24                ' i have 24 components on "stream1"


 

Cells(2,  ITEM).value
= ambildata.ComponentMolarFractionValue(ITEM - 1)


 

Next ITEM

===================================================

 

 

hope this help, I'm sorry for late respond.

 

Alex

 


 



#12 Dacs

Dacs

    Gold Member

  • Members
  • 393 posts

Posted 04 March 2013 - 12:44 AM

I think you forgot to mention these on your post:

1. You need to use VBA to execute that

2. You did not include the initialization of simCase, which should be either a class that belongs to Hysys.SimulationCase or Hysys.Application

 

:)



#13 Sathya R

Sathya R

    Veteran Member

  • ChE Plus Subscriber
  • 35 posts

Posted 04 March 2013 - 04:17 AM

Hysys Stream Reporter can be used generate the data in Excel. This utility can be found in the internet or will be given as part hysys basic training. If you have token system, you can use aspen simulation work book to link the data to excel.



#14 hetianbiao

hetianbiao

    Brand New Member

  • Members
  • 4 posts

Posted 11 March 2013 - 11:30 PM

I think VBA is necessary for hysys link to excel



#15 RockDock

RockDock

    Gold Member

  • Members
  • 257 posts

Posted 12 March 2013 - 09:13 AM

Wow. That seems a lot more difficult than it is in ProMax. In ProMax, you just right click on on any value and select export to excel.

 

Or you can use the scenario tool demonstrated here:

 



#16 Dacs

Dacs

    Gold Member

  • Members
  • 393 posts

Posted 12 March 2013 - 06:54 PM

ProMax is run with Visio, so I suppose exporting to Excel would be easier than with Hysys



#17 Process Eng

Process Eng

    Brand New Member

  • Members
  • 1 posts

Posted 07 September 2013 - 05:08 AM

Hi everybody ;

Please try the following steps to link Hysys to Excel:

  • open your simulation case
  • open a new excel sheet
  • copy the value to be linked to excel (for example the mass density) you can use (Ctrl+C)
  • go to the new excel sheet, click on the right button of the mouse and select special paste.
  • the table of special paste will appear; select coller avec liaison (or paste with link) and select text, then OK.

Now if you change for example the related temperature on your simulation case you can see that the value of mass density will change in the excel sheet. By this method you can link all your required data to the excel.

I hope that this can help you.

regards.



#18 sacarove

sacarove

    Gold Member

  • Members
  • 54 posts

Posted 26 September 2013 - 04:02 AM

Dear all,

i am back with the exporting composition to hysys.

 

I am getting an error saying object does not support this propriety or method.

 

Attached is the code.

 

Option Explicit

Public hyApp As HYSYS.Application
Public simCase As SimulationCase
Public pStream As ProcessStream
Public Sub StartHYSYS()
Dim filename As String
Dim ITEM As Integer
Dim STREAM1 As Streams, STREAM2 As Streams
Dim Compositions As Variant
'Loading customation throgh excel to access stream components
'Loading hysys simulation file
 ' LOADING HYSYS SIMULATION FILE
    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
        
  'Read Data from Excel to stream
  Set pStream = simCase.Flowsheet.MaterialStream.ITEM("STREAM1")
  Compositions = pStream.ComponentMolarFractionValue
  For ITEM = 0 To 11 ' Collect composition data as variant
        Compositions(ITEM) = Worksheets("HYSYS").Range("D" & ITEM + 7).Value
        'Cells(6, ITEM).Value = pStream.ComponentMolarFractionValue(ITEM - 1)
        
  Next ITEM
  
  'Apply composition data
  pStream.ComponentMolarFraction.Values = Compositions
  
  'Write composition data from HYSYS to Excel from stream3
  Set pStream = simCase.Flowsheet.MaterialStreams.ITEM("Stream3")
  For ITEM = 0 To 11 'number of components are 12
  
  ' component molar fraction
Worksheets("HYSYS").Range("E" & ITEM + 7).Value = pStream.ComponentMolarFraction(ITEM)
  ' component mass flowrate
Worksheets("HYSYS").Range("F" & ITEM + 7).Value = pStream.ComponentMassFlow(ITEM)
   ' component molar fraction
Worksheets("HYSYS").Range("G" & ITEM + 7).Value = pStream.ComponentMolarFlow(ITEM)
Next ITEM
 
 'FINISH
        
End Sub
 
 
Thanks
Sacarove


#19 Bobby Strain

Bobby Strain

    Gold Member

  • Members
  • 3,529 posts

Posted 26 September 2013 - 10:56 PM

Before you can import stream compositions, you must set the array in HYSYS by setting each component flow to 0. Then all will work well. There may be an example on the AspenTech site.

 

Bobby



#20 sacarove

sacarove

    Gold Member

  • Members
  • 54 posts

Posted 27 September 2013 - 05:26 AM

Thanks Bod,

I was making some mistakes on the code.

It is now running.

Sacarove



#21 sacarove

sacarove

    Gold Member

  • Members
  • 54 posts

Posted 30 September 2013 - 04:23 AM

Dear All,

I am having an Out of range error  on the code below:

 
    For ITEM = 1 To 4
    p_length(ITEM - 1) = Cells(6, ITEM + 2)
        p_elev(ITEM - 1) = Cells(7, ITEM + 2)
        p_odiam(ITEM - 1) = Cells(8, ITEM + 2)
        p_idiam(ITEM - 1) = Cells(9, ITEM + 2)
        p_rough(ITEM - 1) = Cells(10, ITEM + 2)
        p_cond(ITEM - 1) = Cells(11, ITEM + 2)
 
Can anybody help on this error?
 
Thanks
 
Sacarove


#22 sacarove

sacarove

    Gold Member

  • Members
  • 54 posts

Posted 18 November 2013 - 09:19 AM

Dear all,

i want to fetch  a value from the spreadsheet I have in hysys.

How the vba code would look like?

 

Thanks

Sacarove



#23 siphe2013

siphe2013

    Brand New Member

  • Members
  • 1 posts

Posted 12 December 2013 - 03:30 AM

Thank you thank you thank you! I was getting a just a little bit annoyed because I couldn't get the values from my case file to update on my aspen workbook in excel, this has helped me a lot! :)

 

Hi everybody ;

Please try the following steps to link Hysys to Excel:

  • open your simulation case
  • open a new excel sheet
  • copy the value to be linked to excel (for example the mass density) you can use (Ctrl+C)
  • go to the new excel sheet, click on the right button of the mouse and select special paste.
  • the table of special paste will appear; select coller avec liaison (or paste with link) and select text, then OK.

Now if you change for example the related temperature on your simulation case you can see that the value of mass density will change in the excel sheet. By this method you can link all your required data to the excel.

I hope that this can help you.

regards.

 



#24 masebinu

masebinu

    Brand New Member

  • Members
  • 4 posts

Posted 15 December 2013 - 06:02 AM

hi all, please does any one have a code that i can use to generate a user defined module for a membrane in Aspen plus. i am stocked and can make much progress with my simulation.



#25 aliisd

aliisd

    Brand New Member

  • Members
  • 1 posts

Posted 03 April 2015 - 04:01 AM

Hi everybody ;

Please try the following steps to link Hysys to Excel:

  • open your simulation case
  • open a new excel sheet
  • copy the value to be linked to excel (for example the mass density) you can use (Ctrl+C)
  • go to the new excel sheet, click on the right button of the mouse and select special paste.
  • the table of special paste will appear; select coller avec liaison (or paste with link) and select text, then OK.

Now if you change for example the related temperature on your simulation case you can see that the value of mass density will change in the excel sheet. By this method you can link all your required data to the excel.

I hope that this can help you.

regards.

Hello everybody,

 

Do you know how to export data from excel to HYSYS, as well? 

 

Thank you very much,

Regards






Similar Topics