Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,570
- Office Version
- 365
- 2016
- Platform
- Windows
This code checks to see if a file (tar_str) exists in a directory.
"tar_str" consists of a trailing wildcard as it will locate the one file (if it exists) in the directory that is of the flavour "_3.xlsx", "_5.xlsx" or "_6.xlsx".
So, now that such a file is determined to exist, how can I get that file's full name (to include the portion represented by the asterisk)? I need to now open it, and I can't open a workbook with a wildcard.
Code:
Sub cheese()
sdate = 43609 'May 24 2019
EDate = 43757 'Oct 20 2019
Days = 148
For lp = sdate To EDate
t_mon = Format(lp, "mmm")
t_day = Day(lp)
t_dayy = Format(lp, "ddd")
tar_str = t_mon & "-" & t_day & " (" & t_dayy & ") Schedule_*"
srcfile = tar_str
strFileName = srcpath & srcfile
strFileExists = Dir(strFileName)
If strFileExists = "" Then
MsgBox "The selected file doesn't exist"
Else
MsgBox "The selected file exists"
End If
lp = lp + 1
Next lp
End Sub
"tar_str" consists of a trailing wildcard as it will locate the one file (if it exists) in the directory that is of the flavour "_3.xlsx", "_5.xlsx" or "_6.xlsx".
So, now that such a file is determined to exist, how can I get that file's full name (to include the portion represented by the asterisk)? I need to now open it, and I can't open a workbook with a wildcard.
Last edited: