Table of contents
TOC
折叠目录
展开目录

Application.TemplatePaths 属性 (Visio)Application.TemplatePaths Property (Visio)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

获取或设置 Microsoft Visio 查找模板的位置的路径。读/写。Gets or sets the paths where Microsoft Visio looks for templates. Read/write.

语法Syntax

表达式TemplatePathsexpression . TemplatePaths

表达式_一个表示应用程序对象的变量。_expression A variable that represents an Application object.

返回值Return Value

StringString

注解Remarks

TemplatePaths属性设置为空字符串 (""),默认情况。The TemplatePaths property is set to an empty string ("") by default.

传递和接收到来自TemplatePaths属性是在文件位置对话框中显示的同一字符串的字符串。(单击文件选项卡,单击选项,单击高级,然后单击常规下的文件位置。)此字符串存储在HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Visio\Application\TemplatePath子项中。The string passed to and received from the TemplatePaths property is the same string shown in the File Locations dialog box. (Click the File tab, click Options, click Advanced, and then, under General, click File Locations.) This string is stored in the HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Visio\Application\TemplatePath subkey.

当 Visio 模板查找时,查找名为TemplatePaths属性和上述路径的所有子文件夹中的所有路径。如果将TemplatePaths属性传递给EnumDirectories方法,它返回在传递中文件夹的完全限定路径的完整列表。When Visio looks for templates, it looks in all paths named in the TemplatePaths property and all the subfolders of those paths. If you pass the TemplatePaths property to the EnumDirectories method, it returns a complete list of fully qualified paths in the folders passed in.

TemplatePaths属性设置为文件位置对话框中的模板替换现有值。要保留现有值,请获取现有字符串,然后将新文件路径附加到该字符串,如下面的代码所示:Setting the TemplatePaths property replaces existing values for Templates in the File Locations dialog box. To retain existing values, get the existing string and then append the new file path to that string, as shown in the following code:

Application.TemplatePaths = Application.TemplatePaths &; ";" &; "newpath ".

警告: 是否在注册表编辑器中或以编程方式修改注册表以任何方式,总会带来一定程度的风险。不正确的修改会导致严重的问题,可能需要您重新安装操作系统。最好总是计算机的注册表首先备份之前不对其进行修改。如果您运行的 Microsoft Windows NT 或 Microsoft Windows 2000,您还应该更新紧急修复磁盘 (ERD)。Caution Modifying the registry in any manner, whether in the Registry Editor or programmatically, always carries some degree of risk. Incorrect modification can cause serious problems that may require you to reinstall your operating system. It is a good practice to always back up a computer's registry first before modifying it. If you are running Microsoft Windows NT or Microsoft Windows 2000, you should also update your Emergency Repair Disk (ERD).

示例Example

此 Microsoft Visual Basic for Applications (VBA) 宏显示如何使用TemplatePaths属性路径添加到模板路径框中。This Microsoft Visual Basic for Applications (VBA) macro shows how to use the TemplatePaths property to add a path to the Templates paths box.


Public Sub TemplatePaths_Example()  

    Dim strMessage As String 
    Dim strNewPath As String 
    Dim strTemplatePath As String 
    Dim strTitle As String 

    'Get the path we want to add.  
    strTemplatePath = Application.TemplatePaths  
    strTitle = "TemplatePaths"  
    strMessage = "The current content of the Visio Templates path box is:"  
    strMessage = strMessage &; vbCrLf &; strTemplatePath  
    MsgBox strMessage, vbInformation + vbOKOnly, strTitle  
    strMessage = "Type in an additional path for Visio to look for templates. "  
    strNewPath = InputBox$(strMessage, strTitle)  

    'Make sure the folder exists and that it's not 
    'already in the Templates path box.  
    strMessage = ""  
    If strNewPath = ""  Then 
        strMessage = "You did not enter a path." 
        ElseIf InStr(strTemplatePath, strNewPath)  Then 
            strMessage = "The path you specified is already in the Templates path box."  
        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.TemplatePaths = strTemplatePath &; ";" &; strNewPath  
            strMessage = "We just added " &; strNewPath &; _  
                " to the Templates path box."  
    End If 

    If strMessage <> ""  Then 
        MsgBox strMessage, vbExclamation + vbOKOnly, strTitle  
    End If  

End Sub
© 2018 Microsoft