Frequently asked questions for self help.

Knowledge base article 101

Run macros from Hyperlinks

A neat way to provide the "glue" that links documents to macro code, macros can be run using the hyperlink function.

Example using Spreadsheet

  1. Create simple macro - select Tools/Macro/Macros
  2. In the Macro name box, type TestMacro and click Create
  3. Below the line "Sub TestMacro", enter:
    MsgBox "Hello"
  4. Use the Windows menu to return to the spreadsheet
  5. In a spare cell, type:
    =Hyperlink("#TestMacro", "Click here")

NB: You don't have to put in Click here - any description will do.

Now you can click the hyperlink "Click Here" to run the macro - a simple message box will appear.

The hash symbol (#) above is used to denote a macro (as opposed to a normal URL). The macro in this case is an Application level macro and is available for any Spreadsheet. It's also possible to run a macro in a document. In this case, the syntax is:

=HYPERLINK("documentname#macroname", "Click here")

For example, a user called Phil, with a macro called "startit" in a spreadsheet called myspread stored in my documents would enter:

=HYPERLINK("C:\Documents and Settings\Phil\My Documents\myspread.aws#startit", "Click here")

The HYPERLINK function can be used in a similar way in Write (use Insert/Hyperlink) and Database (create a calculated field to hold the function - see Knowledge Base Article 82: Creating a database of hyperlinks for an example).