Manage VBA codes of Visio Macro-Enabled diagram.

Add a VBA Module

The following sample code adds a new VBA Module and Macro Code and saves the output in the VSDM format. Once, you will open the output VSDMĀ file in Microsoft Visio and click the Developer > Visual Basic menu commands, you will see a module named “TestModule” and inside it, you will see the following macro code.

 Sub ShowMessage()

    MsgBox "Welcome to Aspose!"

End Sub

Here is the sample code to generate the output VSDMĀ file with VBA Module and Macro Code.

Modify VBA or Macro

The following sample code loads the source Visio file which has a following VBA or Macro code inside it

 Sub Button1_Click()

    MsgBox "This is test message."

End Sub

After the execution of Aspose.Diagram sample code, the VBA or Macro code will be modified like this

 Sub Button1_Click()

    MsgBox "This is Aspose.Diagram message."

End Sub

You can download the source Visio file and the output Visio file from the given links.

Advance topics