Share via


VBProject Property [Visio 2003 SDK Documentation]

Returns a programmable object that you can use to control the Microsoft Visual Basic for Applications (VBA) project of the document.

objRet = object**.VBProject**

objRet     Programmable object that exposes methods and properties of the document's VBA project.

object     Required. An expression that returns a Document object.

Version added

4.5

Remarks

To get information about the object returned by the VBProject property

  1. On the Tools menu, point to Macros, and then click Visual Basic Editor.
  2. In the Visual Basic Editor, on the Tools menu, click References.
  3. In the References dialog box, click Microsoft Visual Basic for Applications Extensibility, and then click OK.
  4. On the View menu, click Object Browser.
  5. In the Project/Library list, select the VBIDE type library.
  6. In the Classes list, examine the class named VBProject.

If no VBA project already exists in the document, the VBProject property creates one.

Beginning with Visio 2002, the VBProject property raises an exception if you are running in a security-enhanced environment and your system administrator has blocked access to the Visual Basic object model. There is no user interface or programmatic way to turn this on—the system administrator must turn on (or off) access by setting a Group Policy. This helps protect against viruses that spread by accessing the Visual Basic projects in commonly used templates and injecting the virus code into them.

Example

This VBA macro shows how to print the names of libraries referenced by a VBA project in the Immediate window.

Before running this code, make sure the Trust access to Visual Basic Project check box is selected on the Trusted Publishers tab in the Security dialog box (on the Tools menu, click Options, click the Security tab, and then click the Macro Security button).

Public Sub VBProject_Example() 

    Dim varThisProject As Variant
    Dim intReferences As Integer

    Set varThisProject = ThisDocument.VBProject 

    intReferences = varThisProject.References.Count 
    While intReferences > 0 
        Debug.Print varThisProject.References(intReferences).Name 
        intReferences = intReferences - 1 
    Wend

End Sub

Applies to | Document object

See Also | VBE property