共用方式為


DocumentBase.VBProject Property

Gets the Microsoft.Vbe.Interop.VBProject for the document.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

Syntax

'Declaration
Public ReadOnly Property VBProject As VBProject
public VBProject VBProject { get; }

Property Value

Type: Microsoft.Vbe.Interop.VBProject
The Microsoft.Vbe.Interop.VBProject for the document.

Remarks

Use this property to gain access to code modules and user forms.

Examples

The following code example uses the VBProject property to display the name of the Visual Basic for Applications project for the document. To use this example, run it from the ThisDocument class in a document-level project.

Private Sub DocumentVBProject()
    MessageBox.Show("The name of the VB project is: " & Me.VBProject.Name)
End Sub
private void DocumentVBProject()
{
    MessageBox.Show("The name of the VB project is: " +
        this.VBProject.Name);
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace