VBAEnabled property

VBAEnabled property

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

See also         Example         Applies to

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

Version added

2002

Syntax

        
          boolRet = object.VBAEnabled
      

boolRet

Boolean. True indicates that VBA is enabled in the application; otherwise, False.

object

Required. An expression that returns an Application object.

Remarks

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

  • Visio no longer executes macros in those documents, but the macro names still appear on the Macros menu.
  • Visio continues firing events to the project.

If a document with 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 Enable Microsoft Visual Basic for Applications check box is selected on the Advanced tab in the Options dialog box (on the Tools menu click Options). 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 opening a document that depends on VBA.

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

  Public Sub CheckVBAEnabled()
Dim docObj As Visio.Document
Dim status As Boolean

status = Application.VBAEnabled
  If Not status Then
MsgBox "VBA must be enabled for this process to continue." & _
" Please enable VBA and start over."
Else
Set docObj = Documents.Open("filename")
Endif

End Sub