Try this code (note that I added FileName = Dir
in the end of the While
loop):
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