Using Wildcard on Workbooks.Open

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to use a wildcard on the Workbooks.Open command, but it doesn't
recognize the wilcard character as being a wildcard but part of the filename.
I'm concatenating two string variables into the filename. Any idea if this
will work?

Code:
Workbooks.Open Filename:="\\Yucca\" & Name1 & "_" & Name2 & "*.xls"
 
Hi Stever,
I want to use a wildcard on the Workbooks.Open command, but it doesn't
recognize the wilcard character as being a wildcard but part of the
filename. I'm concatenating two string variables into the filename.
Any idea if this will work?

Code:
Workbooks.Open Filename:="\\Yucca\" & Name1 & "_" & Name2 & "*.xls"

You can't use wildcards with the Open method - you'll have to determine the
exact filename. You could use the Dir$() function to ascertain the actual
filename given the wildcard-based one, then pass the actual filename to the
Open method.

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top