Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB code to "open file" in Excel (Wildcard)

Status
Not open for further replies.

belstoy

Technical User
May 31, 2005
37
US
I am currently trying to write code to open a file in excel that may or may not have a date stamp. Is there a wildcard I can use to open this file whether it is named "Status File" or "Status File 013107". I am currently using the following:
[Workbooks.Open Filename:="C:\My Documents\Status File.xls"]

Please advise,
Belstoy
 
You may want to check if the file exists:
Code:
MyFile = Dir("C:\My Documents\Status File*.xls")
and try to open it:
Code:
[Workbooks.Open Filename:=MyFile ]

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top