VBAEnabled Property [Visio 2003 SDK Documentation]
Specifies whether Microsoft Visual Basic for Applications (VBA) is enabled in the application.
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.
Version added
2002
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 Enable Microsoft Visual Basic for Applications check box is selected on the Security tab in the Options dialog box (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.
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("filename")
End if
End Sub
Applies to | Application object | InvisibleApp object
See Also | MacrosEnabled property