Opening a file with date extension
Ivan,
This what I have so far:
Dim wb As Workbook
spath = Application.DefaultFilePath
sfilename = "Competitor Pricing Monitor Update.*.xls"
If Len(Dir(spath & "\" & sfilename)) = 0 Then
MsgBox "No file"
Else
sfilename = spath & "\" & Dir(spath & "\" & sfilename)
'set wb = workbooks.open sfilename
End If
The 'set wb = workbooks.open sfilename' has turned red
Not much good at this am I?
What am I missing?
"Ivan Raiminius" wrote:
Hi John,
sPath = "C:\test"
sFilename = "My Import File*.xls"
if len(dir(spath & "\" & sfilename))=0 then
msgbox "No file"
else
sFilename = spath & "\" & dir(spath & "\" & sfilename)
dim wb as workbook
set wb = workbooks.open sfilename
end if
You can move "dim wb as workbook" into top of the procedure, if you
prefer this location or to the top of the module to be able to work
with wb in other procedures within the module.
Regards,
Ivan
|