## Integrating Macros in OfficeReports tables and charts

OfficeReports enables the user to define advanced tables and charts. You can customize the Table and chart content and layout by adding macros to the specific table or chart types.

For Excel, the macro file is named: XLSMacros.xlam

For PowerPoint the macro file is named: PPMacros.pptm

Single User installation: Add Macros to the macro files placed in the folder: C:\Users\Public\OfficeReports\template

Multi User installation: Add Macros to the macro files placed in the folder: \OfficeReports\template in the defined network drive.

If OfficeReports is installed on a network drive please use the folder: \OfficeReports\template” at the network drive.

The macro is called from the table and chart types defined in ‘Layout’à’General Layout Definitions’. By opening the Layout Definition module, we can define that we want to run a macro on specific table and chart styles.

Now, when we call this specific table or chart style the macro will run automatically.

Observe

This feature requires the OfficeReports Analytics Pro version.

The macros used in OfficeReports have to take a workbook as parameter, and have to return a string. Use the workbook parameter to get the sheets and the chart to work with. Do NOT use ActiveSheet and ActiveChart! The string returned should be an error message, or "OK" if there is no problem:

`Function MyMacro(wb As Workbook) as String`
`'Declarations`
`On Error GoTo ErrHandler:`
`'Code`
`MyMacro = "OK"`
`Exit Function`
`ErrHandler:`
`MyMacro = "MyMacro Macro Failed: " & Err.Description`
`End Function`