Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Using the SAP2000 v18 API in VBA

Using the SAP2000 v18 API in VBA

Using the SAP2000 v18 API in VBA


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 ?


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

   '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 

RE: Using the SAP2000 v18 API in VBA

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.

RE: Using the SAP2000 v18 API in VBA

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close