我在 Aspen HYSYS V9 中构建了一个模拟模板,并希望使用 VBA 自动化将列内部结构的数据(例如内部类型、托盘/填料类型和末端阶段)从 Excel 表传输到 HYSYS。我没有在对象浏览器中找到内部结构,所以我尝试使用后门变量访问内部结构。为了找出这个绰号,我录制了一个脚本,在该脚本中,我打开了一个列的“内部”页面,并将类型从托盘式更改为包装式,然后再改回托盘式。该脚本显示以下内容:
Message "FlowSht.1/UnitOpObject.400(Regenerator)" "view"
Message "FlowSht.1/UnitOpObject.400(Regenerator)/FlowSht.600" "MakeMeActiveColumnOp"
SpecWhileSolving Specify "FlowSht.1/UnitOpObject.400(Regenerator)" ":Enum.590.0" 0.000000000000e+000
SpecWhileSolving Specify "FlowSht.1/UnitOpObject.400(Regenerator)" ":Enum.590.0" 0.000000000000e+000
SpecWhileSolving Message "FlowSht.1/UnitOpObject.400(Regenerator)/FlowSht.600" "MakeMeActiveColumnOp"
Specify "FlowSht.1/UnitOpObject.400(Regenerator)" ":PageNumber.0" 1.000000000000e+001
SpecWhileSolving Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709" 0.000000000000e+000
Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709" 0.000000000000e+000
SpecWhileSolving Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Selection.711.0" 1.000000000000e+000
Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709" 0.000000000000e+000
Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709" 0.000000000000e+000
SpecWhileSolving Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Selection.711.0" 0.000000000000e+000
Specify "Utility.300(Internals-1@Main Tower@COL4)" ":Index.709" 0.000000000000e+000
然后我写了下面的vba代码:
Dim hyfs As Flowsheet
Dim hyfsBD As BackDoor
Dim hyBDVar As RealVariable
Set hyfs = hycase.Flowsheet
Set hyfsBD = hyfs
Set hyBDVar = hyfsBD.BackDoorVariable("Utility.300(Internals-1@Main Tower@COL1)" & ":Selection.711.0").Variable
hyBDVar.SetValue 1, ""
但 hyBDVar 的返回值为 -32767,我收到一条错误消息:“对象“InternalRealVariable”的“设置值”方法失败。”