Guys, do you know how can I run a simulationin Aspen Dynamics in a Step Mode using VBA code?
I studied the Aspen Simulation Workbook and there is a macro which does something similar, but it only runs the simulation.
What I'm doing is changing the values that I want to input into the simulation in Aspen Dynamics, Waiting Some Seconds, Running the Simulation, Pausing it and Restarting, like the code below:
Sub Test()
Dim i as Integer
For i = 3: 500
Worksheets("Sheet1").Range("D8") = Worksheets("Tags").Range("G" & i)
Worksheets("Sheet1").Range("D9") = Worksheets("Tags").Range("H" & i)
Worksheets("Sheet1").Range("D10") = Worksheets("Tags").Range("I" & i)
Application.Wait (Now + TimeValue("0:00:5"))
Application.Run ("AspenSimulationWorkbook.xla! ASWRunActiveSimulation")
Application.Run ("AspenSimulationWorkbook.xla! ASWPauseActiveSimulation")
Next i
End Sub
What I realized is that if I don't use Application.Wait (Now + TimeValue("0:00:5")), even in a for loop, the time to change cells values is faster than the time to do the task of running and pausing the simulation. I don't know why either. This problem makes me lose some input data during the action.
But, what I really wanted to do was not run and pause simulation, but step it. I believe that using the step my problem with the time to run the simulation could be solved.
Does anyone know how to do this?