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
- 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.
For additional details, refer to https://support.office.com/en-us/article/show-the-developer-tab-e1192344-5e56-4d45-931b-e5fd9bea2d45.
- 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.
Type Sheet1.[A1].Value = "Hello
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
Run your macro:
select the Run Sub/User Form tool
- Save your spreadsheet file.