FlexPro
HistoryBase
Engineering
Training
Downloads
FlexPro Support
Knowledge
Community
About us
References
Jobs
General Contact
List Of Retailers
FlexPro Support
EN
DE
FR
Placeholder

FlexPro Documentation 2025

Recording a Macro to Generate Code

If you are not sure which Visual Basic method or property to use, you can activate macro recording and execute the process manually. Macro recording converts your actions to Visual Basic code. Once your actions have been recorded, you can adapt the code to your needs. If, for example, you are unsure which property or method is used to activate the cursors in the current diagram, do the following:

1.Click Developer[Code] > Record Macro.

2.If necessary, change the default name for the macro and click OK to start recording.

3.Click 2D Diagram Design[Cursors] > On/Off.

4.Click Developer[Code] > Stop Recording.

5.Click Developer[Code] > Macros.

6.Select the newly recorded macro from the list and click Edit.

Take a look at the Visual Basic code that sets the property corresponding to the activation state of the cursors. Position the cursor on CursorActive and press F1, or click Help. Within a topic, you can then view examples and objects that support the CursorActive property (click on Applies to).

Remarks   Recorded macros often use the Selection object to manipulate the elements selected. For example, the following statement carries out a recording when you assign the color red to the selected curve of a diagram.

ActiveDatabase.ActiveObject.Selection.LineFormat.Color = fpColorRed

If you do not want the recorded code to use the Selection object, you have to edit the object using its Properties dialog box while recording a macro. In this case, the following code is recorded:

ActiveDatabase.ActiveObject.Curves(1).Line.LineFormat.Color = fpColorRed

You can also edit the recorded macro manually. You can find information on how to do this under Revising Recorded Visual Basic Macros.