OpenFile



Your Ad Here

Syntax

SapObject.SapModel.File.OpenFile

VB6 Procedure

Function OpenFile(ByVal FileName As String) As Long

Parameters

FileName

The full path of a model file to be opened in the Sap2000 application.

Remarks

This function opens an existing Sap2000 file. The file name must have an sdb, $2k, s2k, xls, or mdb extension. Files with sdb extensions are opened as standard Sap2000 files. Files with $2k and s2k extensions are imported as text files. Files with xls extensions are imported as Microsoft Excel files. Files with mdb extensions are imported as Microsoft Access files.

This function returns zero if the file is successfully opened and nonzero if it is not opened.

The function is only applicable when you are accessing the Sap2000 API from an external application. It will return an error if you call it from VBA inside Sap2000.

VBA Example

Sub OpenSDB()
   'dimension variables
      Dim SapObject As Sap2000.SapObject
      Dim SapModel As cSapModel
      Dim FileName as String
      Dim ret as Long

   'create Sap2000 object
      Set SapObject = New SAP2000.SapObject

   'start Sap2000 application
      SapObject.ApplicationStart

   'create SapModel object
      Set SapModel = SapObject.SapModel

   'initialize model
      ret = SapModel.InitializeNewModel

   'open an existing file
      FileName = "C:\SapAPI\Example 1-019a.sdb"
      ret = SapModel.File.OpenFile(FileName)

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

Release Notes

Initial release in version 11.00.

See Also

ApplicationStart

Save

Return to SAP2000 Index


Your Ad Here