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

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

问题描述

在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)
尽管Len(strFile)> 0
Debug.Print strFile'< - 在立即窗口中查看; Ctrl + g会带你到达
strFile = Dir
Loop
End Sub


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

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

解决方案

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天全站免登陆