Question:
How can I open and close RFEM/RSTAB in the background via the COM interface?
Answer:
By initializing a variable of the Application (interface) type with "new", RFEM/RSTAB is started in the background. With this variable, you can also create a new model using the "CreateModel" method, or close the program using the "Close" command.
The following example shows how to start RSTAB, create a model with a node in the program, and close the program:
Sub RSTAB_open_close()
Dim filename As String
filename = Application.ActiveSheet.Cells(7, 3)
' start rfem
Dim iApp As RSTAB8.Application
Set iApp = New RSTAB8.Application
iApp.LockLicense
iApp.Show
On Error GoTo E
' create model
Dim iMod As RSTAB8.IModel2
Set iMod = iApp.CreateModel(filename)
' add data to model
Dim nd As RSTAB8.Node
nd.no = 10
nd.X = 1
nd.Y = 2
nd.Z = 3
Dim iModdata As RSTAB8.iModelData
Set iModdata = iMod.GetModelData
iModdata.PrepareModification
iModdata.SetNode nd
iModdata.FinishModification
iMod.Save filename
E: If Err.Number 0 Then MsgBox Err.description, , Err.Source
Set iModdata = Nothing
Set iMod = Nothing
iApp.UnlockLicense
iApp.Close
Set iApp = Nothing
End Sub
The "iApp.Show" command is optional. This allows displaying the program normally, not in the background.
Under Downloads, you can find an Excel macro with the subroutines for RFEM and RSTAB.
Please note that the folder where the file is created must exist.