Share via


Application.VBAEnabled Property

Visio Automation Reference

Specifies whether Microsoft Visual Basic for Applications (VBA) is enabled in the application. Read-only.

Version Information
 Version Added:  Visio 2002

Syntax

expression.VBAEnabled

expression   A variable that represents an Application object.

Return Value
Boolean

Remarks

If a document that contains a VBA project is opened with VBA enabled, and then VBA becomes disabled while the document is open:

  • Microsoft Office Visio no longer executes macros in that document, but the macro names still appear on the Macros menu.
  • Visio continues firing events to the project.

If a document that contains a VBA project is opened with VBA disabled, and then VBA becomes enabled while the document is open:

  • Visio does not fire events to the project, even though VBA has become enabled.
  • Macros remain disabled.

The VBAEnabled property is set to True if the Trust access to the VBA project object model check box is selected under Developer Macro Settings on the Macro Settings page of the Trust Center (Tools menu). If it is not selected, the property reports False.

Example

You may have a document that requires VBA to be enabled to run properly, for example, code in a document's DocumentOpened event handler. The following code can be run from an add-on to verify whether VBA is enabled in the application before a document that depends on VBA is opened.

Before running this procedure, supply a valid document file name for the variable filename.

Visual Basic for Applications
  Public Sub VBAEnabled_Example()
Dim vsoDocument As Visio.Document
Dim blsStatus As Boolean

blsStatus = Application.VBAEnabled 
If Not blsStatus Then

    MsgBox "For this process to continue, VBA must be enabled." & _
    " Please enable VBA and start over."

Else

    Set vsoDocument = Documents.Open("<em>filename</em>")

End if

End Sub

See Also