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.
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 PROJECT_FILENAME = "<YOUR_PATH><FILENAME>" Const QUICK_LAUNCH_PATH = "%appdata%\Idera\ERStudio\XML\<QUICK_LAUNCH_FILENAME>.rpo" 'ER/Studio Variables Dim diag As Diagram Sub Main Debug.Clear #Region "Get project" If (Not (DiagramManager.ActiveDiagram Is Nothing)) And (LCase(DiagramManager.ActiveDiagram.GetFullFilePath) = LCase(PROJECT_FILENAME)) Then Set diag = DiagramManager.ActiveDiagram Else ' Load the dm1 file Set diag = DiagramManager.OpenFile(PROJECT_FILENAME) End If #End Region If Not (diag Is Nothing) Then ' Generate the report diag.GenerateReport(QUICK_LAUNCH_PATH) Debug.Print "Report generated" ' Close the project DiagramManager.CloseDiagram(diag.FileName) Else 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.
In this blog post, we learned how to use:
- the ER/Studio Data Architect Report Generation
- to save its settings with the Quick Launch
- the ER/Studio Data Architect COM automation interface through a macro
- to generate a report using saved settings
A short video which shows how to create a macro from a script in ER/Studio Data Architect: