傳回一個陣列,命名給定路徑清單的情況下,Microsoft Visio 將搜尋的資料夾。
語法
運算式。EnumDirectories (PathsString, NameArray () )
expression 代表 Application 物件的變數。
參數
| 名稱 | 必要/選用 | 資料類型 | 描述 |
|---|---|---|---|
| PathsString | 必要 | 字串 | 以分號分隔之完整路徑或部分路徑的字串。 |
| NameArray () | 必要 | 字串 | 輸出參數。 會接收列舉之資料夾名稱的陣列。 |
傳回值
無
註解
AddonPaths 和 TemplatePaths 等數個 Visio 屬性接受並接收字串,該字串會解譯為路徑 (資料夾的清單) 名稱以分號分隔。 當應用程式尋找具名路徑中的項目時,會尋找資料夾及其所有子資料夾。
EnumDirectories 方法的目的是要接受一個字串 (例如 AddonPaths 屬性可能產生的字串),以及在處理這類字串時,傳回應用程式會列舉的資料夾清單。
如果 EnumDirectories 方法成功, NameArray () 會傳回 n 個字串的一維陣列,索引範圍為 0 到 n - 1。 每個字串都是存在之資料夾的完整名稱。 清單會命名路徑清單中指定的已存在的資料夾及其所有子資料夾。
NameArray () 參數是由 EnumDirectories 方法配置的 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 支援與意見反應。