我的VBA代码只返回目录的第一个文件,而它应该返回至少3个文件,有没有人知道这里有什么线索?
FolderName = Environ("UserProfile") + "\"
FilePath = FolderName & "Invoice." & Format(Date,"yyyy.mm.dd") & "-" & "*" & ".ods"
count = 1
FileName = Dir(FilePath)
While (FileName <> "" And count < 5)
MsgBox "FileName = " + FileName
count = count + 1
Wend
答案 0 :(得分:0)
试试这段代码(请注意,我在FileName = Dir
循环的末尾添加了While
):
FolderName = Environ("UserProfile") + "\"
FilePath = FolderName & "Invoice." & Format(Date,"yyyy.mm.dd") & "-" & "*" & ".ods"
count = 1
FileName = Dir(FilePath)
While (FileName <> "" And count < 5)
MsgBox "FileName = " + FileName
count = count + 1
FileName = Dir
Wend