cagri
cagri

Reputation: 71

VBA - Excel SAP2000 API - Automation Error

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

Answers (2)

user6933448
user6933448

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

cagri
cagri

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

Related Questions