In the this set of steps, you will
instantiate OpenSTAAD and have the spreadsheet macro retrieve information from the open
STAAD.Pro model.
This is required in order to access OpenSTAAD API from within your code. It’s a two part process in VBA: You
first declare something as the object and then direct the that object at OpenSTAAD.
-
Within your subroutine, type
Dim
objOpenSTAAD As Object
.
Notice how as you begin typing the word Object
, a small list opens
with relevant terms. This is called IntelliSense and it can help you quickly
and accurately complete code lines.
Note: As Visual Basic requires that objects be declared and assigned a type, it
is a good practice to prefix the name with what type is used. Here, the
prefix obj
is used to describe an object. Later you’ll use different
prefixes to describe variable types.
-
Press Return.
-
Type
Set objOpenSTAAD =
GetObject(,”StaadPro.OpenSTAAD”)
This assigns the OpenSTAAD application object to the variable you
defined in Step 1.
Note: This approach connects to the first instance of
STAAD.Pro that was started where multiple instances exist. You can
alternately specify a specific file path and name to connect to the instance
of the application with that file open.
-
Press Return.