Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the SAP2000 v18 API in VBA

Status
Not open for further replies.

etienne201

Structural
Jul 20, 2016
4

As anyone here successfully used the API in VBA?
Even after adding the reference to SAP2000v18.TLB, the example from the documentation doesn't work.

I get an error 429 "ActiveX component can't create object" at line 8 ("set SapObject = Create...)

Is there anything else that typicality need to be change before using the API ?


Code:
Sub RunSapAnalysisModel()
   'dimension variables
      Dim SapObject As cOAPI
      Dim SapModel As cSapModel
      Dim ret As Long

   'create Sap2000 object
      Set SapObject = CreateObject("CSI.SAP2000.API.SapObject")

   'start Sap2000 application
      SapObject.ApplicationStart

   'create SapModel object
      Set SapModel = SapObject.SapModel

   'initialize model
      ret = SapModel.InitializeNewModel

   'create model from template
      ret = SapModel.File.New2DFrame(PortalFrame, 3, 124, 3, 200)

   'save model
      ret = SapModel.File.Save("C:\SapAPI\x.sdb")

   'run model (this will create the analysis model)
      ret = SapModel.Analyze.RunAnalysis

   'close Sap2000
      SapObject.ApplicationExit False
      Set SapModel = Nothing
      Set SapObject = Nothing
End Sub
 
Replies continue below

Recommended for you

We are experiencing similar issues with SAP18 API and VBA running in EXCEL.
After reporting to CSI, they answered that many customers have the same problem when running simultaneously 64 bits version of SAP and 32 bits version of Office, and suggested installing 32 bits version of SAP.
I don't know if that is your case.
Unfortunately we haven't found the moment to make any further tests, but I hope at least to have put some light on your question.
We would really appreciate your report in case you find a solution.
 
thanks for the info. I was using sap2000 x64 with office x32.

Using VB.Net in Visual studio Community worked fine and was a lot easier than programming in vba/excel. The only problem I've been having so far is the Results.JointRespSpec() function that gives me the wrong results but I didn't need it for my project.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor