If you have not previously created any macros in Microsoft Office Excel, use
this procedure to access the developer tools and set up a VBA module.
-
Open an empty spreadsheet in Microsoft Office Excel.
-
Turn on the Developer ribbon tab:
-
Select Options from the
File ribbon tab.
The Excel Options dialog
opens.
-
Select the Customize Ribbon tab in the
dialog.
-
Check the Developer option in the
Main Tabs list.
-
Click OK.
-
In Excel, select the Visual Basic tool in the
Code group on the Developer
ribbon tab.
The Microsoft Visual Basic for Applications window
opens. This is the development environment in which you will write your VBA code
to have Excel interact with STAAD.Pro via OpenSTAAD.
-
Select .
A new folder (named Modules) and an empty Module
is added to the VBA Project.
-
Create a subroutine which will contain your code:
-
In the Module1(Code) window, type
Sub OS_Tutorial()
-
Press Return.
The coding tool automatically adds the End Sub
code for
you.
-
Press Tab to indent your code.
Tip: Though not necessary to make your code function well, indenting
and aligning code can make it much easier to read by people. It is a good
practice to indent the code within a subroutine, and indent additionally
within If statements or other children of the subroutine.
-
Type
Sheet1.[A1].Value = "Hello
World"
.
-
Run your macro:
- select
- select the Run Sub/User Form tool
- press F5
Your spreadsheet (in the Excel program window) now says Hello
World
in cell A1.
-
Save your spreadsheet file.
Note: You will have to save this Excel Spreadsheet as a Excel
Macro-Enabled Workbook (*.xslm)
format to maintain the VBA macro
you just wrote.
While having your computer return Hello World!
may be a classic example of a
first program, it is not a very practical tool. However, you now have a file set up
to create a more useful OpenSTAAD project in your next example.