Defining a macro

To define a macro:

  1. In the Microsoft Excel template, press ALT - F11 to start the VBA editor.
  2. In the VBA editor, select the Insert menu and from the Insert menu, select Module to define a new module.
  3. In the VBA editor window, define a function for each property attribute that you defined in the template as described in the previous procedure. For property attribute DOC_ID, for example, enter the following code:
    Function getDOC_ID (temp As Integer) As String getDOC_ID=ActiveWorkbook.CustomDocumentProperties("DOC_ID").Value 
    End Function
    

Note that the function name, getDOC_ID, consists of two parts:

  • get
  • DOC_ID

DOC_ID is the name of the property. This macro will fill the cell that is selected in the following procedure.