Visio) (Application.StartupPaths 屬性

會取得或設定 Microsoft Visio 在應用程式啟動時,用來尋找協力廠商和使用者附加元件的路徑。 讀取/寫入。

語法

運算式StartupPaths

expression 代表 Application 物件的變數。

傳回值

字串

註解

StartupPaths 屬性預設會設定為空字串 ("")。

傳遞至 StartupPaths 屬性並從中接收的字串,與 [ 檔案位置 ] 對話方塊中顯示的字串相同。 (按一下 [檔案] 索引 標籤,依序按一下 [ 選項]、[ 進階],然後按一下 [一 ] 底下的 [ 檔案位置) 此字串會儲存在 HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Visio\Application\StartupPath 子機碼中。

當應用程式尋找協力廠商和使用者啟動附加元件檔案時,它會查看 StartupPaths 屬性中名為 的所有路徑,以及安裝程式所安裝之任何啟動附加元件的路徑,以及這些路徑的所有子資料夾。 如果您將 StartupPaths 屬性傳遞給 EnumDirectories 方法,它會在傳入的資料夾中傳回完整路徑的完整清單。

設定StartupPaths屬性會取代 [檔案位置] 對話方塊中StartupPaths的現有值。 若要保留現有的值,請取得現有的字串,然後將新的檔案路徑附加到該字串中,如下列程式碼所示:

Application.StartupPaths = Application.StartupPaths & ";" & "newpath ".

警告

以任何方式修改 Windows 登錄,不論是在登錄編輯程式中還是以程式設計方式,都一律會有某種程度的風險。 不正確的修改會導致嚴重的問題,而可能需要重新安裝作業系統。 因此,較理想的做法是在每次修改電腦的登錄之前先行進行備份。

範例

這個 Microsoft Visual Basic for Applications (VBA) 宏會示範如何使用 StartupPaths 屬性將路徑新增至 [啟動 路徑] 清單。

Public Sub StartupPaths_Example() 
  
    Dim strMessage As String 
    Dim strNewPath As String 
    Dim strStartupPath As String 
    Dim strTitle As String  
 
    'Get the path we want to add.  
    strStartupPath = Application.StartupPaths  
    strTitle = "StartupPaths"  
    strMessage = "The current content of the Visio Start-up paths box is:"  
    strMessage = strMessage & vbCrLf & strStartupPath  
    MsgBox strMessage, vbInformation + vbOKOnly, strTitle  
    strMessage = "Type in an additional path for Visio to look for add-ons. "  
         
    strNewPath = InputBox$(strMessage, strTitle)  
 
    'Make sure the folder exists and that it's not 
    'already in the Start-up paths box.  
    strMessage = ""  
 
    If strNewPath = ""  Then 
        strMessage = "You did not enter a path." 
    ElseIf InStr(strStartupPath, strNewPath)  Then 
        strMessage = "The path you specified is already in the Start-up paths 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 empty)." 
    Else 
        Application.StartupPaths = strStartupPath & ";" & strNewPath 
        strMessage = "We just added " & strNewPath & _  
                " to the startup paths." 
    End If 
       
    If strMessage <> ""  Then 
        MsgBox strMessage, vbExclamation + vbOKOnly, strTitle  
    End If 
  
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應