Application.EnumDirectories 方法 (Visio)Application.EnumDirectories Method (Visio)

在给定路径列表的情况下,返回命名 Microsoft Visio 要搜索的文件夹的数组。Returns an array naming the folders Microsoft Visio would search, given a list of paths.


expressionexpression. EnumDirectories( _PathsString_ , _NameArray()_ )

expression:一个表示 Application 对象的变量。expression A variable that represents an Application object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
PathsStringPathsString 必需Required StringString 由分号分隔的完整路径或部分路径的字符串。A string of full or partial paths separated by semicolons.
NameArray()NameArray() 必需Required StringString 输出参数。Out parameter. 接收枚举的文件夹名称的数组。An array that receives the enumerated folder names.

返回值Return value



多个 Visio 属性,如AddonPathsTemplatePaths接受和接收解释为路径 (文件夹) 名称由分号分隔的列表的字符串。Several Visio properties such as AddonPaths and TemplatePaths accept and receive a string interpreted to be a list of path (folder) names separated by semicolons. 当应用程序查找命名路径中的项目时,则它类似文件夹和所有子文件夹中。When the application looks for items in the named paths, it looks in the folders and all their subfolders.

EnumDirectories方法的用途是接受一个字符串,例如AddonPaths属性可能会产生和应用程序枚举处理此类字符串时返回的文件夹的列表。The purpose of the EnumDirectories method is to accept a string such as one that the AddonPaths property might produce and return a list of the folders that the application enumerates when processing such a string.

如果EnumDirectories方法成功,则_NameArray()_ 返回_n_个字符串索引为 0 到_n_ -1 的一维数组。If the EnumDirectories method succeeds, NameArray() returns a one-dimensional array of n strings indexed from 0 to n - 1. 每个字符串是文件夹的存在的完全限定的名称。Each string is the fully qualified name of a folder that exists. 列表名称中存在的路径列表和及其所有子文件夹指定这些文件夹。The list names those folders designated in the path list that exist and all their subfolders.

NameArray() 参数是由EnumDirectories方法,分配的 out 参数,并且所有权传递回呼叫者。The NameArray() parameter is an out parameter that is allocated by the EnumDirectories method, and ownership is passed back to the caller. 呼叫者最终应返回的数组上执行SafeArrayDestroy过程。The caller should eventually perform the SafeArrayDestroy procedure on the returned array. (Microsoft Visual Basic 和 Visual Basic for Applications 自动释放引用的数组项的字符串。)(Microsoft Visual Basic and Visual Basic for Applications automatically free the strings referenced by the array's entries.)


下面的示例演示如何使用EnumDirectories方法来打印 (在即时窗口中) 的所有文件夹 Visio 搜索加载项列表。The following example shows how to use the EnumDirectories method to print (in the Immediate window) a list of all the folders Visio searches for add-ons.

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 
End Sub

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.