gpt4 book ai didi

vba - 如何获取目录中所有带有ESY扩展名的文件列表?

转载 作者:行者123 更新时间:2023-12-02 01:52:49 24 4
gpt4 key购买 nike

在VBA中,如何获取特定目录中具有特定扩展名的所有文件的列表?

我无法执行Application.FileSearch,因为我使用的是 Excel 2007

最佳答案

为了回应您的评论“那么我知道要运行多少次?”,此示例将一直运行,直到列出名称与 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

关于vba - 如何获取目录中所有带有ESY扩展名的文件列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3017318/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com