Use Microsoft Visual Basic for Applications (VBA) macros to customize report processing beyond the standard report-template features. In addition to Word's standard VBA events, IRT Cronista calls specially named macro procedures at specific points during report generation and editing.
Macros are intended for advanced report-template authors. Use them only when report elements and settings cannot provide the required result.
Available macro callbacks
·ThermoReportStarted(Doc): Runs once after the report document is created from the template and before image data sections are added.
·ThermoReportFrameAdded(Doc, FrameSectionIndex, NewSection): Runs after each report data section is created and filled. One data section can contain multiple infrared images.
·ThermoReportFinished(Doc): Runs once after all data sections are filled, the template's pattern sections are removed, and summary tables are updated.
·ThermoReportDocPropertiesChanged(Doc): Runs after the user confirms changes in the Document Properties dialog and the corresponding Word fields are updated. See Document properties.
·ThermoReportSummaryTableUpdated(Doc, SummaryTable): Runs after the user updates a summary table with the Update command. See Add a summary table.
During generation, the callbacks run in this order: ThermoReportStarted, ThermoReportFrameAdded for each data section, and ThermoReportFinished. If the Document Properties dialog then opens, ThermoReportDocPropertiesChanged runs after the user confirms it. ThermoReportSummaryTableUpdated runs only for the explicit Update command, not for the automatic summary-table update during report generation.
The callback arguments are:
·Doc: The generated or edited Word Document.
·FrameSectionIndex: The Long index of the Word section that was filled.
·NewSection: A Boolean value that indicates whether a new Word section was created. The current report-generation workflow passes True.
·SummaryTable: The Word Table that was updated.
Add macro callbacks to a template
1.Open the report template for editing.
2.Use the Alt+F11 keyboard shortcut to open the Visual Basic Editor.
3.In the Project Explorer, select the template's TemplateProject.
4.Select Insert > Module.
5.Add the required public procedures to the new standard module.
Public Sub ThermoReportStarted(Doc As Document)
'Your code here
End Sub
Public Sub ThermoReportFrameAdded(Doc As Document, _
FrameSectionIndex As Long, NewSection As Boolean)
'Your code here
End Sub
Public Sub ThermoReportFinished(Doc As Document)
'Your code here
End Sub
Public Sub ThermoReportDocPropertiesChanged(Doc As Document)
'Your code here
End Sub
Public Sub ThermoReportSummaryTableUpdated(Doc As Document, _
SummaryTable As Table)
'Your code here
End Sub
6.Save the template as a Word Macro-Enabled Template (.dotm).
Important: Word must allow the template's macros to run. Follow your organization's macro-security policy, and use only trusted macro-enabled templates. |
IRT Cronista continues processing when a callback is not present or Word cannot run it. Test each macro-enabled template and verify the generated report.