Application.StencilPaths 属性 (Visio)

获取或设置 Microsoft Visio 查找模具的路径。 读/写。

语法

表达式模具路径

expression:表示 Application 对象的变量。

返回值

String

备注

默认情况下,StencilPaths 属性设置为空字符串 ("")。

StencilPaths 属性传递和从该属性中接收的字符串是在“文件位置”对话框中显示的同一字符串。 (单击“ 文件 ”选项卡,依次单击“ 选项”、“ 高级”,然后在“ 常规”下单击“ 文件位置”。) 此字符串存储在 HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Visio\Application\StencilPath 子项中。

当 Visio 查找模具时,它将在 StencilPaths 属性命名的所有路径及其所有子文件夹中查找。 如果将 StencilPaths 属性传递给 EnumDirectories 方法,它将返回传入的文件夹中的完全限定路径的完整列表。

设置 StencilPaths 属性将替换“文件位置对话框中模具的现有值。 要保留现有值,请获取现有字符串,然后将新文件路径追加到该字符串,如以下代码中所示:

Application.StencilPaths = Application.StencilPaths & ";" & "newpath ".

警告

以任何方式修改 Windows 注册表(无论是在注册表编辑器中还是在以编程方式)始终都会带来一定程度的风险。 不正确的修改会导致严重的问题,可能需要重新安装操作系统。 最好在修改计算机的注册表之前始终对其进行备份。

示例

以下 Microsoft Visual Basic for Applications (VBA) 宏显示如何使用 StencilPaths 属性添加模具的路径。

 
Public Sub ShowStencilPaths_Example() 
  
    Dim strMessage As String 
    Dim strNewPath As String 
    Dim strStencilPath As String 
    Dim strTitle As String 
 
    'Get the path we want to add.  
    strStencilPath = Application.StencilPaths  
    strTitle = "StencilPaths"  
    strMessage = "The current content of the Visio Stencils box is:"  
    strMessage = strMessage & vbCrLf & strStencilPath  
    MsgBox strMessage, vbInformation + vbOKOnly, strTitle  
    strMessage = "Type in an additional path for Visio to look for stencils. "  
    strNewPath = InputBox$(strMessage, strTitle)  
 
    'Make sure the folder exists and that it's not 
    'already in the stencil paths.  
    strMessage = ""  
    If strNewPath = ""  Then 
        strMessage = "You did not enter a path." 
        ElseIf InStr(strStencilPath, strNewPath)  Then 
            strMessage = "The path you specified is already in the stencil paths."  
        ElseIf Len(Dir$(strNewPath, vbDirectory)) = 0 And _  
                Len(Dir$(Application.Path & strNewPath, _  
                vbDirectory)) = 0 Then 
            strMessage = "The folder you typed does not exist (or is blank)."  
        Else 
            Application.StencilPaths = strStencilPath & ";" & strNewPath  
            strMessage = "We just added " & strNewPath & _  
                " to the stencil paths."  
        End If 
   
    If strMessage <> ""  Then 
        MsgBox strMessage, vbExclamation + vbOKOnly, strTitle  
    End If 
   
End Sub

支持和反馈

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