How to link Hysys Simulation to Excel?
Open Example1.HSC. This file is generated in Aspen Hysys V7.1, may not work in previous version of Hysys, such as Hysys 2006 or Hysys 3.2. If you have older version of Hysys, make your own simulation with two streams named FEED1 and FEED2. Here is some operating condition of the streams.
Linking between Hysys Simulations and Excel using Macro VBA (Visual Basic Application). Create new module in Macro VBA and put this code.
Option Explicit
Public hyApp As HYSYS.Application
Public simCase As SimulationCase
' LOADING HYSYS TUTORIAL FILE
Set hyApp = CreateObject("HYSYS.Application") hyApp.Visible = True Set simCase = hyApp.ActiveDocument If simCase Is Nothing Then fileName = Worksheets("inputhysys").Range("c2") If fileName <> "False" And simCase Is Nothing Then Set simCase = GetObject(fileName, "HYSYS.SimulationCase") simCase.Visible = True End If End If
Note: I put directory address of Hysys file (HSC file) in cell C2. And the address is H:\BLOG\hysys\example1.hsc.
PUT HSC FILE IN YOUR DIRECTORY, MAKE SURE YOU EDIT EDIT THE DIRECTORY ADDRESS, OR HYSYS FILE WILL NOT BE LOADED
How to Access Hysys Streams from Excel?
Put this code to make link to Hysys Streams
Public FEED1 As ProcessStream, FEED2 As ProcessStream
Set FEED1 = simCase.Flowsheet.MaterialStreams.Item("FEED1")How to Export Data from Excel To Hysys Simulation?
How to Import Data from Hysys Streams to Excel File?
Write down this code to export and import data from and to excel
Set FEED1 = simCase.Flowsheet.MaterialStreams.Item("FEED1")Worksheets("Sheet1").Range("D6").Value = FEED1.MassFlow.GetValue("LB/HR") ' import data MASS FLOWRATE from hysys streamsWorksheets("Sheet1").Range("D7").Value = FEED1.Pressure.GetValue("PSIG") ' import data PRESSURE from hysys streamsWorksheets("Sheet1").Range("D8").Value = FEED1.Temperature.GetValue("C") ' import data TEMPERATURE from hysys streams
Set FEED2 = simCase.Flowsheet.MaterialStreams.Item("FEED2") PRESSFEED2 = Worksheets("Sheet1").Range("H7").Value FEED2.Pressure.SetValue PRESSFEED2, "PSIA" ' export pressure FLOWFEED2 = Worksheets("Sheet1").Range("H6").Value FEED2.MolarFlow.SetValue FLOWFEED2, "MMSCFD" ' export molar flowrate TEMPFEED2 = Worksheets("Sheet1").Range("H8").Value FEED2.Temperature.SetValue TEMPFEED2, "F" ' export temperature
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Hysys file can be found here
Excel file can be found here
MAKE SURE TO PUT CORRECT DIRECTORY ADDRESS OF HYSYS FILE IN CELL
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Here is complete code from example.xls
Option Explicit
Public hyApp As HYSYS.Application
Public simCase As SimulationCase
Public FEED1 As ProcessStream, FEED2 As ProcessStream
Public Sub StartHYSYS()
Dim fileName As String
Dim PRESSFEED2 As Double, FLOWFEED2 As Double, TEMPFEED2 As Double
' LOADING HYSYS TUTORIAL FILE
Set hyApp = CreateObject("HYSYS.Application")
hyApp.Visible = True
Set simCase = hyApp.ActiveDocument
If simCase Is Nothing Then
fileName = Worksheets("Sheet1").Range("c2")
If fileName <> "False" And simCase Is Nothing Then
Set simCase = GetObject(fileName, "HYSYS.SimulationCase")
simCase.Visible = True
End If
End If
Set FEED1 = simCase.Flowsheet.MaterialStreams.Item("FEED1")
Worksheets("Sheet1").Range("D6").Value = FEED1.MassFlow.GetValue("LB/HR") ' import data MASS FLOWRATE from hysys streams
Worksheets("Sheet1").Range("D7").Value = FEED1.Pressure.GetValue("PSIG") ' import data PRESSURE from hysys streams
Worksheets("Sheet1").Range("D8").Value = FEED1.Temperature.GetValue("C") ' import data TEMPERATURE from hysys streams
Set FEED2 = simCase.Flowsheet.MaterialStreams.Item("FEED2")
PRESSFEED2 = Worksheets("Sheet1").Range("H7").Value
FEED2.Pressure.SetValue PRESSFEED2, "PSIA" ' export pressure
FLOWFEED2 = Worksheets("Sheet1").Range("H6").Value
FEED2.MolarFlow.SetValue FLOWFEED2, "MMSCFD" ' export molar flowrate
TEMPFEED2 = Worksheets("Sheet1").Range("H8").Value
FEED2.Temperature.SetValue TEMPFEED2, "F" ' export temperature
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Hysys Stream Parameters and units can be found here. REMEMBER TO TYPE UNIT AND PARAMETER AS DESCRIBED HERE. hysys training , hysys tutorial
hi.this is a very nice blog to guide a newbie in hysys-excel automation. thanks for sharing. anw, I have a question here. Can you do the hysys-excel automation without opening the hysys file?? I want to do this since it'll be more simple and save our cpu workspace. I've tried it but got some problems in the "ActiveDocument" syntax. is there any solution to do this?? thanks.
ReplyDeleteHi budibadibu, edit this code
ReplyDelete"Set hyApp = CreateObject("HYSYS.Application") hyApp.Visible = True"
by this one
"Set hyApp = CreateObject("HYSYS.Application") hyApp.Visible = FALSE"
Basically, your hysys file is remainingly active, but invisible. It may save you cpu workspace. But I prefer to let it visible, so I'll know if my simulation is getting divergen.
Hope that's help.
thanks for your answer =D. But i still get trouble with it. The message box will pop up and tell :
ReplyDeleterun-time error'91: Object variable or With block variable not set
here is all of my syntax for this sub, hope you can help me =D thank you very much.
Public hycase As SimulationCase
Public hyApp As HYSYS.Application
Public hyOps As Operations
Public hyFeed1, hyFeed2, hyFeed3, hyFeed4
Public hyFS
Public hyMix As MixerOp
Public hysysPath As String
Public hyPipes As PipeSegment
Public Sub HYSYSAuto()
'How to make connection from HYSYS and EXCEL
hysysPath = Sheets("coba").Range("a1")
Set hyApp = CreateObject("HYSYS.Application")
hyApp.Visible = False
'hyApp.SimulationCases.Open _
hysysPath
Set hycase = hyApp.ActiveDocument
Set hyFS = hycase.Flowsheet (the debugger stop here)
Set hyOps = hyFS.Operations
'Assigning variable to material streams
Set hyFeed1 = hyFS.MaterialStreams("DRJ-01")
Set hyFeed2 = hyFS.MaterialStreams("DRJ-02")
Set hyFeed3 = hyFS.MaterialStreams("DRJ-03")
Set hyFeed4 = hyFS.MaterialStreams("DRJ-04")
Set hyMix = hyOps.Item("MIX-100")
MsgBox "Connection made."
End Sub
thanks for the answer =D. but i stil get trouble with it. The message box will pop up like this :
ReplyDeleteRun-time error'91':Object variable or With block variable not set
Below is all of my syntax for this sub. hope u can help me =D. Thank you very much for your help.
Public hycase As SimulationCase
Public hyApp As HYSYS.Application
Public hyOps As Operations
Public hyFeed1, hyFeed2, hyFeed3, hyFeed4
Public hyFS
Public hyMix As MixerOp
Public hysysPath As String
Public hyPipes As PipeSegment
Public Sub HYSYSAuto()
'How to make connection from HYSYS and EXCEL
hysysPath = Sheets("coba").Range("a1")
Set hyApp = CreateObject("HYSYS.Application")
hyApp.Visible = False
'hyApp.SimulationCases.Open _
hysysPath
Set hycase = hyApp.ActiveDocument
Set hyFS = hycase.Flowsheet (* the debugger will stop here)
Set hyOps = hyFS.Operations
'Assigning variable to material streams
Set hyFeed1 = hyFS.MaterialStreams("DRJ-01")
Set hyFeed2 = hyFS.MaterialStreams("DRJ-02")
Set hyFeed3 = hyFS.MaterialStreams("DRJ-03")
Set hyFeed4 = hyFS.MaterialStreams("DRJ-04")
Set hyMix = hyOps.Item("MIX-100")
MsgBox "Connection made."
End Sub
hey friends.he2.actually i've solved it by looking your syntax in your post. I didn't look it carefully. Thanks for your help. =D.
ReplyDeleteIt seems your code is not complete yet. hyFeed1 (and other streams) is not set correctly. Your streams declaration is not complete.
ReplyDeleteRemove "Public hyFeed1, hyFeed2, hyFeed3, hyFeed4", try this
"Public hyFeed1 as ProcessStream, hyFeed2 as ProcessStream, hyFeed3 as ProcessStream, hyFeed4 as ProcessStream"
(all paramater/streams you can type in single line, but you must declare by each stream/parameter you have.
For example, by typing this code
Public hyFeed1, hyFeed2, hyFeed3, hyFeed4 as ProcessStream
only hyFeed4 is declared as processstream, but others are not declared as processstream (hyFeed1, hyFeed2 and hyFeed3)
Your material streams code is not working, try this one
Set hyFeed1 = hycase.Flowsheet.MaterialStreams.Item("DRJ-01")
Set hyFeed2 = hycase.Flowsheet.MaterialStreams.Item("DRJ-02")
Set hyFeed3 = hycase.Flowsheet.MaterialStreams.Item("DRJ-03")
Set hyFeed4 = hycase.Flowsheet.MaterialStreams.Item("DRJ-04")
haha... you didn't read my post carefully...
ReplyDeletehei buddy. I think i need your help again. hehe. do you know how to call the length of pipe segment from hysys ?? I am struggling with that now. Thanks a lot.
ReplyDeleteum..never tried before. but i think i'm gonna try that.
ReplyDeletebtw, if you want to share your script in my blog, just let me know, i'll post your script here.
haha. Let me know if u have succeed trying that things [=D]
ReplyDeleteOh, that sounds interesting. any email address that I can contact you??
send me an email to akrsuryawan@yahoo.com
ReplyDeletealex
Hey Alex, did you ever figure out how to call the length of a pipe segment or how to assign a cell (in excel) to set the eq-length value (in hysys)?
ReplyDeleteThank you for showing everything that you have!!!!!!
Nice comment. I'll show you how to access pipe segment in hysys.
ReplyDeleteHello,
ReplyDeleteI found your blog very usefull. But I got a problem. How to add a component to component list. I know how to create component list
Dim EXHAUST_GAS As ComponentList
Set EXHAUST_GAS = simCase.BasisManager.FluidPackages.Add("Component_list_1", "Pure")
works for me, but I don't know how to add components to this list.
Hi Wojciech Skrobek,
ReplyDeleteThank for your question and sorry for very late response. I'll make a post to answer your question.
Hi, thank you very much for the tutorial. it is very helpful.
ReplyDeleteI would like to ask about how can i see the list of variable in the hysys to be used on visual basic?
e.g.
i want to extract liquid,gas,and water volume flow from hysys to excel.
i've tried
Worksheets("Sheet1").Range("D6").Value = FEED1.ActualGasFlow.GetValue("m3/h")
but it does not work
Thank you for a great tutorial! Maybe my question would suit better on you other post, "HYSYS TRAINING TO LINK HYSYS VALVE TO EXCEL", but comments seems to be disabled there. Do you know if it's possible to set Valve Opening from Excel and if yes which variable name to use? E.g. VALVE1.xx.SetValue OPENVALVE, "%", what is xx? Thanks!
ReplyDeleteThanks so much, the codes are absolutely helpful for a beginner like me. I am now trying to call for a stream number specified in a cell in Excel to be looked for in HYSYS, instead of directly specifying a particular HYSYS stream in VBA to call for the parameters.
ReplyDeleteHow can I write the codes to this? This will be very helpful in instances where I happen to import parameters from a range of HYSYS streams. It also will allow me to specifically call for the parameters of a group of selected HYSYS streams listed in Excel.
thank you! it is very useful. Some one help me to write data to oil manager.
ReplyDeleteG.S
Hello Sir,
ReplyDeleteYour blog is very helpful.
I need your help for linking excel to hysys. In my case, I am using a heater and I have to vary the heat load with time as well as the inlet and outlet pressure, temperature. I have 40 readings of heat load, pressure and temperature at different time step like 3 sec, 8 sec, 15 seconds and so on... can we simulate this type of problem in aspen hysys 7.1?
Your post on excel advanced training is really useful. I agree with your thoughts, knowledge on excel is mandatory for everyone. Excel Training in Chennai | Advanced Excel Training in Chennai
ReplyDeleteAnyone one knows how to export from excel to hysys controllers and digital points via vba?
ReplyDeleteNice article, Thank you sir, for sharing with us.
ReplyDeleteoracle finance training in chennai
Thanks for sharing the valuable information.
ReplyDeleteandroid training in chennai
Thanks so much for this information. I have to let you know I concur on several of the points you make here and others may require some further review, but I can see your viewpoint.
ReplyDeleteexcel vba courses london
Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
ReplyDeleteBest RPA Training in Chennai
Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
ReplyDeleteHadoop Training Institute In chennai
This is excellent information. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
ReplyDeleteEmbedded training in chennai | Embedded training centre in chennai
All the points you described so beautiful. Every time i read your blog and i am so surprised that how you can write so well.
ReplyDeleteOracle Online Training
This is my 1st visit to your web... But I'm so impressed with your content. Good Job!
ReplyDeleteOracle training in Bangalore
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
ReplyDeleteDevops Training in Chennai
Devops Training in Bangalore
AWS Training in chennai
AWS Training in bangalore
You got an extremely helpful website I actually have been here reading for regarding an hour. I’m an initiate and your success is incredibly a lot of a concept on behalf of me.
ReplyDeletepython training in Bangalore
python training in pune
python online training
This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.
ReplyDeleteBlueprism training in tambaram
Blueprism training in annanagar
Blueprism training in velachery
Have you been thinking about the power sources and the tiles whom use blocks I wanted to thank you for this great read!! I definitely enjoyed every little bit of it and I have you bookmarked to check out the new stuff you post
ReplyDeletejava training in chennai | java training in bangalore
java training in tambaram | java training in velachery
I simply want to give you a huge thumbs up for the great info you have got here on this post.
ReplyDeleteangularjs Training in chennai
angularjs-Training in pune
angularjs-Training in chennai
angularjs Training in chennai
angularjs-Training in tambaram
Whatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing clearly, but it’s no need to do it, because you have explained the concepts very well. It was crystal clear, keep sharing..
ReplyDeleteGerman Classes in Chennai
Java Training in Chennai
best german classes in chennai
German language training in chennai
Java Training Institute in Chennai
Best Java Training Institute in Chennai
Hats off to your presence of mind. I really enjoyed reading your blog. I really appreciate your information which you shared with us.
ReplyDeleteiosh course in chennai
Very nice to read
ReplyDeleteAdvanced Excel Training chennai
This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
ReplyDeleteDevops Training in Chennai | Devops Training Institute in Chennai
Really great post, I simply unearthed your site and needed to say that I have truly appreciated perusing your blog entries.
ReplyDeleteMicrosoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training
This comment has been removed by the author.
ReplyDeleteYour very own commitment to getting the message throughout came to be rather powerful and have consistently enabled employees just like me to arrive at their desired goals.
ReplyDeletePython Training in Chennai| Python Training institute in Chennai
Datascience Training in Chennai |Datascience Training institute in Chennai
RPA Training in Chennai | RPA Training institute in Chennai
DevOps Training in Chennai |DevOps Training institute in Chennai
AWS Training in Chennai |AWS Training institute in Chennai
Azure Training in Chennai | Azure Training institute in Chennai
Thanks for your informative article. Android SDK allows you to create stunning mobile application loaded with more features and enhanced priority. With basis on Java coding language, you can create stunning mobile application with ease.
ReplyDeleteRegrads,
Advanced Excel Training in Chennai | Advanced Excel Training Courses in Chennai | Advanced Excel Certification Training
For IT Softwre Job Training my suggestion Softlogic. Softlogic Provide the Training and Placement for bellow Site dot net training in chennai | angularjs training in chennai | asp.net training in chennai | linux training in chennai | iot training in chennai | android classes in chennai | Excel Training in Chennai
ReplyDeletethanks for sharing the valuable information with us .keep doing on
ReplyDeleteAngularJS Training in Chennai | AngularJS Training in Anna Nagar | AngularJS Training in OMR | AngularJS Training in Porur | AngularJS Training in Tambaram | AngularJS Training in Velachery
"I have read so many articles or reviews however this blog post is genuinely a pleasant article, keep it up. .
ReplyDeleteDigital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in Velachery
"
Thanks for giving great kind of information. So useful and practical for me.
ReplyDeleteDigital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in Velachery
Such a very useful article. Very interesting to read this article. Android Training in Chennai | Certification | Mobile App Development Training Online | Android Training in Bangalore | Certification | Mobile App Development Training Online | Android Training in Hyderabad | Certification | Mobile App Development Training Online | Android Training in Coimbatore | Certification | Mobile App Development Training Online | Android Training in Online | Certification | Mobile App Development Training Online
ReplyDeleteI must appreciate you for providing such a valuable content for us. This is one amazing piece of article. Helped a lot in increasing my knowledge.
ReplyDeleteAngular js Training in Chennai
Angular js Training in Velachery
Angular js Training in Tambaram
Angular js Training in Porur
Angular js Training in Omr
Angular js Training in Annanagar
This content is very great. i loved reading it as it gives me enough information to understand things really quickly. Thanks for sharing
ReplyDeleteSelenium Training in Chennai
Selenium Training in Velachery
Selenium Training in Tambaram
Selenium Training in Porur
Selenium Training in Omr
Selenium Training in Annanagar
Thanks for giving great kind of information. So useful and practical for me.
ReplyDeleteamazon web services aws training in chennai
microsoft azure training in chennai
workday training in chennai
android-training-in chennai
ios training in chennai
It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
ReplyDeleteIELTS Coaching in chennai
German Classes in Chennai
GRE Coaching Classes in Chennai
TOEFL Coaching in Chennai
Spoken english classes in chennai | Communication training
Infycle Technologies, the top software training institute and placement center in Chennai offers the Best Digital Marketing course in Chennai for freshers, students, and tech professionals at the best offers. In addition to Digital Marketing, other in-demand courses such as DevOps, Data Science, Python, Selenium, Big Data, Java, Power BI, Oracle will also be trained with 100% practical classes. After the completion of training, the trainees will be sent for placement interviews in the top MNC's. Call 7504633633 to get more info and a free demo.
ReplyDeletesmm panel
ReplyDeleteSmm Panel
is ilanlari
instagram takipçi satın al
hırdavatçı burada
Www.beyazesyateknikservisi.com.tr
servis
Jeton hilesi indir
hatay
ReplyDeleteığdır
ısparta
mersin
ağrı
TQ4Z
https://saglamproxy.com
ReplyDeletemetin2 proxy
proxy satın al
knight online proxy
mobil proxy satın al
XKOY
great post. Angular Training In Pune
ReplyDeletehttps://bayanlarsitesi.com/
ReplyDeleteGöktürk
Yenidoğan
Şemsipaşa
Çağlayan
FHFP30
Antalya
ReplyDeleteKonya
Adana
Ankara
Van
D5H
Hello,
ReplyDeleteim struggling to find the different phases within the Object browser, hence i can not connect to the specific phase values. Anyone know what could be the reason for this?
Have checked the references and have ticked off almost all of the Aspen ones.
thanks alot!
Çorlu Lojistik
ReplyDeleteManisa Lojistik
Eskişehir Lojistik
Afyon Lojistik
Konya Lojistik
BWİVUİ
amazing post, MEAN Stack Development Course in Pune
ReplyDeleteE65C0
ReplyDeleteNevşehir Şehirler Arası Nakliyat
Çerkezköy Oto Lastik
Tunceli Şehirler Arası Nakliyat
Afyon Şehir İçi Nakliyat
Kocaeli Evden Eve Nakliyat
Sivas Şehir İçi Nakliyat
Artvin Evden Eve Nakliyat
Hakkari Lojistik
Çanakkale Şehirler Arası Nakliyat
76C5C
ReplyDeleteExpanse Coin Hangi Borsada
Kalıcı Makyaj
Etimesgut Parke Ustası
Gölbaşı Parke Ustası
Bolu Lojistik
Bitci Güvenilir mi
Çankaya Parke Ustası
Karapürçek Fayans Ustası
Sakarya Evden Eve Nakliyat
23A79
ReplyDeleteYozgat Evden Eve Nakliyat
Pursaklar Boya Ustası
Trabzon Şehirler Arası Nakliyat
Coinex Güvenilir mi
Okex Güvenilir mi
Kastamonu Evden Eve Nakliyat
Altındağ Parke Ustası
Dxgm Coin Hangi Borsada
Ordu Şehir İçi Nakliyat
6329D
ReplyDeleteÜnye Organizasyon
Balıkesir Şehirler Arası Nakliyat
Kastamonu Lojistik
Çerkezköy Asma Tavan
Samsun Şehir İçi Nakliyat
Isparta Parça Eşya Taşıma
Osmaniye Şehir İçi Nakliyat
Batman Lojistik
Nevşehir Lojistik
DDAAB
ReplyDeleteMeta Coin Hangi Borsada
Muğla Şehir İçi Nakliyat
Konya Parça Eşya Taşıma
Kırklareli Lojistik
Karapürçek Fayans Ustası
Silivri Duşa Kabin Tamiri
Sweat Coin Hangi Borsada
Afyon Şehirler Arası Nakliyat
Keçiören Parke Ustası
9BF0C
ReplyDeleteresimlimagnet
C7514
ReplyDeletehttps://resimlimag.net/
C5A2D
ReplyDeletesightcare
E52EC
ReplyDeleteReferans Kimliği Nedir
Bone Coin Hangi Borsada
Bitcoin Giriş Nasıl Yapılır
Ön Satış Coin Nasıl Alınır
Görüntülü Sohbet
Coin Para Kazanma
Kripto Para Nedir
Telegram Görüntüleme Hilesi
Bitcoin Yatırımı Nasıl Yapılır
3A83C
ReplyDeletedextools
trezor suite
trust wallet
defilama
satoshi
yearn
uwu lend
dexscreener
poocoin
FDSGRFDHGTY
ReplyDeleteشركة تسليك مجاري بالقطيف
DTRSWRT
ReplyDeleteتسليك مجاري بالقطيف
edgtdfhgfrghgh
ReplyDeleteشركة عزل اسطح بالجبيل
صيانة افران بمكه lzpORLiHbD
ReplyDeletetySPjU2rA2
ReplyDeleteشركة صيانة افران بالاحساء GZXAvpAKJ0
ReplyDeleteرقم مصلحة المجاري بالاحساء jhqSoAlsXy
ReplyDeleteشركة عزل اسطح بالقطيف 1WpCM9HqfM
ReplyDelete