l--*_*''' 13 filesystems search file-extension vba excel-2007
在VBA中,如何获取特定目录中具有特定扩展名的所有文件的列表?
我无法做到Application.FileSearch,因为我正在使用excel 2007
Han*_*sUp 13
回应你的评论"所以我知道运行它多少次?" ,此示例将一直运行,直到列出名称与strPattern匹配的所有文件.更改strFolder常量.
Public Sub ListESY()
Const strFolder As String = "C:\SomeFolder\"
Const strPattern As String = "*.ESY"
Dim strFile As String
strFile = Dir(strFolder & strPattern, vbNormal)
Do While Len(strFile) > 0
Debug.Print strFile '<- view this in Immediate window; Ctrl+g will take you there
strFile = Dir
Loop
End Sub
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31742 次 |
| 最近记录: |