QUERY > Running the query > Publishing macros in an Excel workbook
Publishing macros in an Excel workbook
In Query, you can publish macros in Excel workbooks and customize aspects of the variables. You can also edit macros in that are already published to workbooks from within Query without opening VBA. Macros created in Query can be run in the Query and Runner clients and in the Runner add-in for Excel.
- The Excel file that you publish to must be macro enabled.
- No VBA validation of the macro is possible. You must manually ensure the VBA syntax is correct.
To publish a macro
- Create the macro in or copy it to a .txt file.
- In the Run pane, click Publish Macro.
- In the Winshuttle Macro Publisher dialog box, click Import.
Browse to the location of the .txt file.
- Click Save to publish the macro.
To edit macros already published to workbooks
- In the Run pane, click Publish Macro.
- From the list in the Winshuttle Macro Publisher dialog box, select the macro you want to use. Click Edit.
- The text editor opens to accept your changes. Click Save.
To enable a macro as a button in a workbook
Note: Excel files that contain a space in their filename cannot contain buttons.
- In the Run pane, click Publish Macro.
- From the list, select the macro you want to use.
- Click Make Button.
- In the Caption box, name the button and in the Cell Address box and specify where you want the button to appear. Click OK.
To run a macro
- In the Run pane, click Publish Macro.
- From the list, select the macro you want to use. Click Run.
Macro templates
Macro templates are available for you to customize to your needs. To download templates, go to support.winshuttle.com.
The form can be generated from only one method specified in the <MN></MN>
tag. Variables must be coded in the following format:
<WSM_Declaration><VN>Variable Name</VN><LT>Label Text</LT><DV>Default Value</DV><DT>Data Type</DT><MN>Method Name</MN></WSM_Declaration>
To add your own variables
- Click Publish Macro.
- Click Import to import the macro or template.
- Click Edit.
- Add the variables. Click Save.