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

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

语法Syntax

expressionexpression. EnumDirectories( _PathsString_ , _NameArray()_ )

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

参数Parameters

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

返回值Return value

NothingNothing

注解Remarks

多个 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 ()_ 返回一个从0到_n_ -1 索引的_n_个字符串的一维数组。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方法分配的输出参数, 并且将所有权传递回调用方。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.)

示例Example

下面的示例演示如何使用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 
 Wend 
 
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.