會取得或設定 Microsoft Visio 在應用程式啟動時,用來尋找協力廠商和使用者附加元件的路徑。 讀取/寫入。
語法
表情。創業路徑
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 屬性將路徑加入 Startup-up 路徑清單。
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 支援與意見反應。