Reputation: 71
I am trying to start SAP2000 using VBA Excel but I get an error with the message: "Automation Error". The code is very simple:
Sub api()
Dim SapObject As Sap2000.SapObject
Set SapObject = New Sap2000.SapObject
SapObject.ApplicationStart
End Sub
This code should start SAP2000 but it does not.
SAP2000v14 is installed along with Office 2013. I have checked the tick box next to SAP2000 in Tools-References menu.
By the way, I can run SAP2000 using MATLAB.
Thank you!
Upvotes: 1
Views: 2130
Reputation: 11
Here is code for SAP 2000:
Option Explicit
Dim SapObject As SAP2000.SapObject
Dim ret As Long
Dim Coordinates As Range
Sub Sap2000_open()
' Create the Sap2000 object
Set SapObject = CreateObject("SAP2000.SapObject")
SapObject.ApplicationStart
SapObject.SapModel.InitializeNewModel (kgf_m_C)
ret = SapObject.SapModel.File.NewBlank
End Sub
Upvotes: 1
Reputation: 71
Thank you guys. But I have sorted it out. In the compability options of SAP2000.exe, "run as admin" was selected. So I deselected it and it works now.
Upvotes: 1