OS. To create an Excel workbook macro

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.

For additional details on using VBA in Microsoft Office applications, refer to https://docs.microsoft.com/en-us/office/vba/library-reference/concepts/getting-started-with-vba-in-office

  1. Open an empty spreadsheet in Microsoft Office Excel.
  2. Turn on the Developer ribbon tab:
    1. Select Options from the File ribbon tab.
      The Excel Options dialog opens.
    2. Select the Customize Ribbon tab in the dialog.
    3. Check the Developer option in the Main Tabs list.
    4. Click OK.
  3. 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.
  4. Select Insert > Module.
    A new folder (named Modules) and an empty Module is added to the VBA Project.
  5. Create a subroutine which will contain your code:
    1. In the Module1(Code) window, type Sub OS_Tutorial()
    2. Press Return.
      The coding tool automatically adds the End Sub code for you.
  6. Press Tab to indent your code.
  7. Type Sheet1.[A1].Value = "Hello World".

    This assigns the text string as the value of the cell A1 on worksheet Sheet1. This is a shorthand method in Excel VBA, where as you can also use Sheet1.cells(1, 1).Value. You can find details on Excel VBA here: https://docs.microsoft.com/en-us/office/vba/api/excel.worksheet.cells

    https://docs.microsoft.com/en-us/office/vba/excel/concepts/cells-and-ranges/reference-cells-and-ranges

  8. Run your macro:
    • select Run > Run Sub/User Form
    • select the Run Sub/User Form tool
    • press F5
    Your spreadsheet (in the Excel program window) now says Hello World in cell A1.
  9. Save your spreadsheet file.

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.