MacrosEnabled Property [Visio 2003 SDK Documentation]
Specifies whether macros can be executed and events can be processed in a document's Microsoft Visual Basic for Applications (VBA) project.
boolRet = object**.MacrosEnabled**
boolRet Boolean. True to indicate that macros are enabled in the document; otherwise, False.
object Required. An expression that returns a Document object.
Version added
2002
Remarks
If your document contains macros that are necessary to your solution's execution, you can use the MacrosEnabled property to verify whether macros are enabled in the document. If they are disabled, you can display a message indicating that your solution may not work as expected because document settings prohibit macros from being executed.
The value of the MacrosEnabled property depends on a combination of the application's security setting and the project's signature status (whether it is signed by a trusted source). The following table describes these combinations.
Security setting | Signed by a trusted source | MacrosEnabled property |
---|---|---|
Very High |
Yes |
False |
Very High |
No |
False |
High |
Yes |
True |
High |
No |
False |
Medium |
Yes |
True |
Medium |
No (user clicks Disable Macros) |
False |
Medium |
No (user clicks Enable Macros) |
True |
Low |
N/A |
True |
To open a document in a disabled state (macros are not enabled), you can use the OpenEx method of the Document object. For example:
Documents.OpenEx(fileName, visOpenMacrosDisabled)
The macro security setting for the instance is set on the Security Level tab in the Security dialog box (Tools menu, Macros submenu). Trusted sources are listed on the Trusted Publishers and Prior Trusted Sources tabs in the same dialog box.
Example
The following example shows how use to open a document from an add-on and use the MacrosEnabled property to determine whether macros are enabled. If macros are disabled, a message box appears warning the user of limited functionality. Before running this example, supply a valid document file name for the variable filename.
Public Sub MacrosEnabled_Example()
Dim vsoDocument As Visio.Document
Dim blsStatus As Boolean
Set vsoDocument = Documents.Open("filename")
blsStatus = vsoDocument.MacrosEnabled
If Not blsStatus Then
MsgBox "Macro execution has been disabled for this document." & _
" Functionality may be limited."
End if
End Sub
Applies to | Document object
See Also | OpenEx method | VBAEnabled property