Macros

Navigation:  Solicitudes y Macros >

Macros

Previous pageReturn to chapter overviewNext page

Two kinds of macros are used in QDV7:

the QDV macros written in C# or Visual Basic .NET

the Excel macros written in VBA; they do not write to the estimate, but to exported Excel files; the extension xlsm is not supported

 

The macros can be invoked by clicking macro buttons or on particular events.

It is subject to a security setting (Macros). When disabled, you can still execute predefined macros in the group Macros buttons.  

 

Five examples of macros show in the Multi-languages sample. "Sample write to overhead workbook", written in VB .NET, enables you to write to Overhead user sheets.

Two are assigned to macro buttons 2 (QDV macro) and 3 (Excel macro).

 

QDV Macros

QDV API generates pre-compiled programs called Macros. These programs are compiled at run-time on the target computer:

 

0

 

1

2

 

3

MS Visual Studio

 

QDV Program Editor

 

QDV7 Run-time

Edition

Post-edition

Pre-compilation

Compilation

 

Import __

 

 

 

 

 

To create/edit a QDV macro, click Automation>Macros>Macros>Open QDV macro; this opens a dialog box.

To create a macro, click the Create button; this opens the QDV Program Editor; enter the code and click Build>Compile and Save; this adds the macro to the list. For details on the API, refer to the topic on the macro API.

To edit the macro, it is helpful to enter the object name, then a dot and tap into the in-line picker the properties/methods and events.

To add a reference to any assembly in the .NET Framework or to any .NET assembly in the QDV7 installation folder, click Build>References and check the assembly. To reference your own assemblies, make sure they are compiled using the ‘Any CPU’ option under Visual Studio and place them in the installation folder; you can deploy them automatically to all of your client computers using the publishing tool (located in the installation folder).

 

To export a macro:

without programmer license, in the dialog box, click the button Export

with programmer license, it is also possible from the editor: select the pane Projects>Projects, select the macro and right click Save Macro As

 

To import a macro, click the button Import and select the macro among the files with extension qdvmacro; as there is no compilation, a programmer license is not required.

Procedure (the step numbers are also the numbers in the table above):

1.To post-edit a QDV macro, select it and click the Edit button (alternative: double click); this opens the QDV Program Editor

2.To pre-compile the macro, click Build>Compile and Save  

3.To run the macro using the Macro menu, click Run Macro, select the macro and click the Run button  

 

Refresh_Current_View() is used inside a loop to update the minutes right away, in particular before acknowledging the message QDV_Editor stating the number of writes.

 

Macros in the Multi-languages sample:

Sample Extract Workbooks: used to generate Nomenclatures (the workforce-only Minutes are listed at the beginning), or test WBS report with various profiles

Sample which exports an article database: it exports <installation folder>\Samples\databases_of_articles\Sample_Article_DB.qdb to Excel

Sample write to Overhead Workbook: it modifies the color of a rectangle in Overhead>Test_Macros; to secure the estimate, first the macro gets a lock on the overhead workbook (Es.GetLockOnWorkbook) and after the execution, it releases the lock (Es.ReleaseLockOnWorkbook)  

Sample_Program_CSharp: it is used by the 2rd dedicated button

Sample_Program_VisualBasic: same effect as the preceding

 

To run a macro using a dedicated button or on an event, refer to Events Management. To run the macro example, click the 2rd button; this opens a dialog box

 

Excel Macros

To create/edit a macro, click Automation>Macros>Macros>Open Excel macro; this opens a dialog box.

To create a macro, right-click and select New Macro.

To import a macro, right-click, select Load Macro and select the macro among the files with extension qdvxlmacro; this opens a dialog box.

To edit a macro, right-click it and select Edit Macro; this opens a dialog box: in the lower part, specify the macro full path and the macro name in Excel (Alt F8); in the upper parts, specify which estimate components must be exported to Excel and their destination full path.

To test a macro, select it and click the Proceed button.

 

To run a macro using the Macro menu, click Open Macro Excel, select the macro and click the Run button.

To run a macro using a dedicated button or on an event, refer to Events Management. To run the macro example, click the 3rd button; in Excel, the macro name is TESTME; this exports the Condensed WBS to Excel and creates the file Overhead.xls in C:\Temp. To export other parts, including the planner into various formats, right click Edit Macro, check the corresponding boxes and select Browse.