如何获取目录中带有 ESY 扩展名的所有文件的列表? [英] How to get list of all files with ESY extension in a directory?

查看:25
本文介绍了如何获取目录中带有 ESY 扩展名的所有文件的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In VBA, how do I get a list of all the files with a specific extension in a specific directory?

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

i am unable to do Application.FileSearch, because i am using excel 2007

推荐答案

回应你的评论那么我知道要运行多少次?",这个例子一直运行,直到它列出所有名称与 strPattern 匹配的文件.更改 strFolder 常量.

In response to your comment "so how many times do i know to run it?", this example runs until it lists all the files whose names match strPattern. Change the strFolder constant.

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

这篇关于如何获取目录中带有 ESY 扩展名的所有文件的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆