Hi i'm triying to link VBA with hysys for calculate some thermodynamic properties of oil, i have to send temperature and pressure to hysys throught a macros for this calculate. Hysys library it's activate on VBA, when i run the code VBA returns me this message:
"Error in load dll library"
My code is:
Option Explicit
Public hyApp As HYSYS.Application
Public simCase As HYSYS.SimulationCase
Public CRUDOBRM As HYSYS.ProcessStream
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'Inicialización de Hysys
Public Sub Oleoducto()
''Variables de HYSYS''
Dim filename As String
Dim PressureHysys As Double
Dim TemperaturaHysys As Double
Dim VaporFractionHysys As Double
''Variables Ingresadas por Usuario''
Dim Caudal As Double 'Caudal de entrada en m3/dia
Dim Pinicial As Double 'Presión inicial en Kg/cm2
Dim Tinicial As Double 'Temperatura inicial
Dim Tambiente As Double 'Temperatura ambiental
Dim HeatLoss As Double 'Perdida de Calor Global
Dim dX As Double 'Paso de Integración del ducto
Dim Psucción As Double 'Presion de Succión Admitida
Dim Vmax As Double 'Velocidad Maxima Permitida
''Apertura de HYSYS para el cálculo de propiedades''
Set hyApp = CreateObject("HYSYS.Application")
hyApp.Visible = True
Set simCase = hyApp.ActiveDocument
If simCase Is Nothing Then
filename = Worksheets("Simulador").Range("c4")
If filename <> "False" And simCase Is Nothing Then
Set simCase = GetObject(filename, "HYSYS.SimulationCase")
simCase.Visible = True
End If
End If
Set CRUDOBRM = simCase.Flowsheet.MaterialStreams.Item("CRUDOBRM")
Cells(6, 6) = CRUDOBRM.Pressure.GetValue("PSGI")
End Sub
The thing it's Early Binding it's not function, with Late Binding i can open the simulation case but I can't manipulate the conditions of the process.
Please Help Me,
Thank's
Edited by Fernando Bórquez, 24 February 2014 - 05:27 PM.