Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

How to Lunch SAP2000v17 in VBA

Status
Not open for further replies.

Rahxephon14

Civil/Environmental
Jul 21, 2015
5
Hi !
I'm using Excel and I want to lunch SAP2000v17 with it but I have a problem with my code. Here is it :

Code:
Option Explicit

Dim SapObject As SAP2000v17.cOAPI
Dim sapmodel As cSapModel
Dim ret As Long

Sub ouvrir_fichier()


Dim nom_fichier As String
Dim chemin As String
Dim kN_m_C As String

Set SapObject = CreateObject("CSI.SAP2000.API.SapObject")

ret = SapObject.ApplicationStart()


ret = SapObject.sapmodel.InitializeNewModel

chemin = Sheets(1).Range("chemin").Value
nom_fichier = Sheets(1).Range("nom_fichier").Value
ret = SapObject.sapmodel.File.OpenFile(chemin & "\" & nom_fichier & ".bdb")
ret = SapObject.sapmodel.SetPresentUnits(kN_m_C)

End Sub

I have always the same error. It says me :

Execution error '429'
An ActiveX component can't create an Object.

I realy don't understand why it doesn't work.

Than you !


 
Replies continue below

Recommended for you

Did you reference SAP2000v17.DLL or SAP2000v17.TLB from your application?
If using Excel VBA, reference SAP2000v17.TLB by opening the VBA editor, clicking the Tools menu > References command and selecting SAP2000v17.TLB from the program installation folder.
 
Yes I'm using Excel and I refere the SAP2000v17.TLB.

But it's still not working...
 
Hi,

1. ret = SapObject.sapmodel.File.OpenFile(chemin & "\" & nom_fichier & ".[highlight #FCE94F]bdb[/highlight]"), This should be .sdb.
2. Remove reference to previous versions, if any.

Cheers!
 
Hi !

I change this thanks !

But it's still not workng :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor