共用方式為


Application.EnumDirectory 方法 (Visio)

回傳一個陣列,命名 Microsoft Visio 會搜尋的資料夾,並給定路徑清單。

語法

表情列舉目錄 (PathsStringNameArray () )

expression 代表 Application 物件的變數。

參數

名稱 必要/選用 資料類型 描述
路徑串 必要 字串 以分號分隔之完整路徑或部分路徑的字串。
NameArray () 必要 字串 輸出參數。 會接收列舉之資料夾名稱的陣列。

傳回值

註解

多個 Visio 屬性如 AddonPathsTemplatePaths 接受並接收一個字串,該字串被解釋為以分號分隔的路徑 (資料夾) 名稱清單。 當應用程式在命名路徑中尋找項目時,會查看資料夾及其所有子資料夾。

EnumDirectories 方法的目的是要接受一個字串 (例如 AddonPaths 屬性可能產生的字串),以及在處理這類字串時,傳回應用程式會列舉的資料夾清單。

EnumDirectory 方法成功, NameArray () 會回傳一個一維陣列,包含 n 個字串,索引範圍為 0 到 n - 1。 每個字串都是存在資料夾的完全限定名稱。 清單會命名路徑清單中指定的資料夾及其所有子資料夾。

NameArray () 參數是由 EnumDirectory 方法分配的 out(out)參數,所有權會回傳給呼叫者。 呼叫者最終會對回傳陣列執行 SafeArrayDestroy 程序。 (Microsoft Visual Basic 與 Visual Basic for Applications 會自動釋放陣列條目所參考的字串 )

範例

下列範例將示範如何使用 EnumDirectories 方法 (在 [即時運算] 視窗中) 顯示 Visio 搜尋附加元件所在的所有資料夾清單。

 
Public Sub EnumDirectories_Example() 
 
 Dim strDirectoryNames() As String 
 Dim intLowerBound As Integer 
 Dim intUpperBound As Integer 
 
 Application.EnumDirectories Application.AddonPaths, strDirectoryNames 
 
 intLowerBound = LBound(strDirectoryNames) 
 intUpperBound = UBound(strDirectoryNames) 
 
 While intLowerBound <= intUpperBound 
 Debug.Print strDirectoryNames(intLowerBound) 
 intLowerBound = intLowerBound + 1 
 Wend 
 
End Sub

支援和意見反應

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