I was wondering if it is possible to get the current active flexsim object through an excel VBA interface. The idea is to retrieve the current active flexsim document and access the elements in it and write certain properties to excel or write back to model from excel.
An example would be say to get the names of all elements in the model to excel, then say i change the names of elements in excel and write it back to the model.
Usually one can use the GetObject() method to get an application
Example: This code retrieves the current CATIA active document and then from the top node, one can move down to access the sub nodes as shown.
Sub CATMain()
Dim CATIA As Object
Set CATIA = GetObject(, "CATIA.Application")
Set openDocument = CATIA.ActiveDocument
Set currentPart = openDocument.Part
Set currentBody = currentPart.Bodies.item(1)
Set currentPad = currentBody.pad
'And so on and so forth working all the way down to the sub-nodes
End Sub
I tried to achieve the same with flexsim, but it doesn't seem to work. The error is written beside each line.
Sub Main()
Dim flexsim As Object
Set flexsim = GetObject(,"FlexSim.Application") ' ActiveX component cannot create object
Set flexsim = GetObject("D:\Flexsim_learning\ExcelFlexsimInterface.fsm") 'File name or class name not found during automation operation
End Sub