Running Macros

Running Macros

You can configure the SaveToDB add-in to launch Excel macros. This way gives additional benefits:

  • ? All possible user actions are located in the Excel context menu and the SaveToDB Actions menu.
  • Macros are linked to specific queries and are available immediately after connecting to data.
  • Macros can have input parameters from table columns, query parameters, and named cells.

Macros can be located in active workbooks or in separate macro workbooks that can be updated independently.

Specify macros in the HANDLER_CODE field in the following format:

<Excel macro> [<Parameter1>[, <Parameter2>[, ...]]

For example:

 dbotestContextMenudboRun HelloWorld MacroMACROHelloWorld

Macros can use context values in the following format: {ParameterName=DefaultValue} or simply {ParameterName}

For example:

SayHello "World"
SayHello {Name=World}
Sheet1.SayHello {FirstName}, {LastName}
MacroWorkbook.xlsm!SayHello {FirstName}, {LastName}

Note that a macro sheet name is an internal Excel name, not a user visible name.
You can check macro names using the Excel dialog box for launching macros (Alt-F8).

Important! Run macros from trusted sources only! SaveToDB does not check macros.