Managing macros

Link the VBA code to an event

Excel > CCH® Tagetik > Design

To link a VBA code to an event, it is necessary to create a public module in which to insert the event declaration and the VBA code to be run when the event occurs.

  1. Open the form in which to insert the VBA code.
  2. Click Excel's Developer tab, then click Visual Basic.
  3. In the VBA project tree, right click the workbook of the desired form, then click Insert > Module.
  4. In the module, create a public function if the result of the function must be used in other operations, or a subroutine if no result needs to be shown.

Call up an API within a macro.

There are two methods that can be used to recall an API within a macro, as described below.

  • Using the following syntax:

dim valoreDiRitorno as

valoreDiRitorno = Application.run("Tgkrmacro.xlam!nomeFunzione", "parametro1", parametro2", ...)

  • Define a button in the form (e.g. CommandButton1) and insert the following example code in the event that manages button pressure:

Private Sub CommandButton1_Click()

Dim wb As Workbook

Set wb = Application.Run ("Tgkrmacro.xlam!TGK_Navigate", "B110_100")

End Sub

In the example, the instruction calls up the opening of the form with code "B110_100" in navigation mode.