Macro to open a workbook whose name changes regularly

Not a guru

New member
Joined
Mar 5, 2014
Messages
2
Reaction score
0
Points
0
Hello everyone
I am trying to write a macro that opens a workbook which is in a specific location. The workbook changes name regularly according to the date it is saved on. But there is only one *.xls file at this location. The location is E:\Reports. The latest filename is 11-3-2014.xls. My attempts doing this have failed so far. ? I would very much like the macro to find this *.xls file and open it, whatever the name will be.
Can anyone help?

Brg. Not an excel guru :)
 

patel

New member
Joined
Feb 20, 2014
Messages
60
Reaction score
0
Points
0
Location
Italy
Excel Version(s)
2010
Code:
Sub OpenFileNoName()
  fpath = "E:\Reports\"
  FoundFile = Dir(fpath & "*.xls")
  If FoundFile <> "" Then
        Workbooks.Open (fpath & FoundFile)
  Else
        MsgBox "No such file!"
  End If
End Sub
 
Top