共用方式為


Application.StencilPaths 屬性 (Visio)

會取得或設定 Microsoft Visio 用來尋找樣板的路徑。 讀取/寫入。

語法

表情模板路徑

expression 代表 Application 物件的變數。

傳回值

字串

註解

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 支援與意見反應