Document.Masters 属性 (Visio)

返回文档模具的 Masters 集合。 此为只读属性。

语法

表达式主人

表达 一个代表 Document 对象的变量。

返回值

Masters

备注

如果 Visual Studio 解决方案包含 Microsoft.Office.Interop.Visio 引用,则此属性映射到以下类型:

  • Microsoft.Office.Interop.Visio.IVDocument.Masters

示例

以下 Microsoft Visual Basic for Applications (VBA) 程序显示如何使用 Masters 属性将当前文档中所有的主控形状名称打印到“立即”窗口。

运行此宏之前,请打开一个 Microsoft Visio 绘图并将模具中的至少一个形状拖动到该绘图页上。

 
Public Sub Masters_Example() 
  
    Dim intCounter As Integer 
    Dim intMasterCount As Integer 
    Dim vsoApplication As Visio.Application  
    Dim vsoCurrentDocument As Visio.Document  
    Dim vsoMasters As Visio.Masters 
 
    Set vsoApplication = GetObject(, "visio.application") 
  
    If vsoApplication Is Nothing Then 
        MsgBox "Microsoft Office Visio is not loaded" 
        Exit Sub   
 
    End If   
 
    Set vsoCurrentDocument = vsoApplication.ActiveDocument  
 
    If vsoCurrentDocument Is Nothing Then 
        MsgBox "No stencil is loaded" 
        Exit Sub   
 
    End If   
 
    Set vsoMasters = vsoCurrentDocument.Masters  
    Debug.Print "Masters in document : "; vsoCurrentDocument.Name  
    intMasterCount = vsoMasters.Count  
 
    If intMasterCount > 0 Then 
        For intCounter = 1 To intMasterCount  
            Debug.Print " "; vsoMasters.Item(intCounter).Name  
        Next intCounter  
    Else 
        Debug.Print " No masters in document"  
    End If   
 
End Sub

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。