How to generate a report from a macro?

by May 9, 2023

In a previous post, I explained how we can schedule an automatic reverse-engineer from a database into a data model.

In this one, I’m sharing an example of a macro which allows you to generate a report from your model. All the other steps from the previous post can also be used with this macro.

The first step is to use the wizard to create a report as you want it and to save the settings for a Quick Launch.

Report Wizard Page 1


In the last page, you must save the settings:

Here is the macro you can use and customize to generate your report using the settings from the Quick Launch file:

'TITLE:  wGenerateReportHTML.BAS
'DESCRIPTION:  This macro generates a HTML report based on a quick launch file for a data model file

Option Explicit

Const QUICK_LAUNCH_PATH = "%appdata%\Idera\ERStudio\XML\<QUICK_LAUNCH_FILENAME>.rpo"

'ER/Studio Variables
Dim diag As Diagram

Sub Main

    If (Not (DiagramManager.ActiveDiagram Is Nothing)) And (LCase(DiagramManager.ActiveDiagram.GetFullFilePath) = LCase(PROJECT_FILENAME)) Then
        Set diag = DiagramManager.ActiveDiagram
        ' Load the dm1 file
        Set diag = DiagramManager.OpenFile(PROJECT_FILENAME)
    End If

    If Not (diag Is Nothing) Then
        ' Generate the report
        Debug.Print "Report generated"

        ' Close the project
        Debug.Print "Project not found: ";PROJECT_FILENAME
    End If
End Sub

To use the above macro, you need to update the constants to match the path to your DM1 file and to your Quick Launch settings.

Then, you can run the macro from your ER/Studio Data Architect UI or from command line.

HTML report


In this blog post, we learned how to use: