在不使用循环的情况下确定文件夹中特定类型的文件 [英] Determine files of a specific type in a folder without using loop

查看:36
本文介绍了在不使用循环的情况下确定文件夹中特定类型的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用VBA中的FileSystemObject来确定文件夹中特定类型(例如.PDF)的文件数,而无需使用诸如循环的

Is there any way to use the FileSystemObject in VBA to determine the number of files of a specific type, such as .PDF, in a folder without using a loop such as

For Each file In folder.Files
    'Check file type and count
Next

推荐答案

您可以在没有FSO依赖的情况下执行此操作,同时也无需手动检查文件扩展名;

You can do this without the FSO dependency while also negating the need to examine the file extension manually;

dim file as String, countOf As Long
file = Dir$("c:\xxxxxx\*.pdf")
Do until file = ""
    countOf = (countOf + 1)
    file = Dir$()
Loop

MsgBox countOf

这篇关于在不使用循环的情况下确定文件夹中特定类型的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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