ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Wildcard on Workbooks.Open (https://www.excelbanter.com/excel-programming/342586-using-wildcard-workbooks-open.html)

Stever

Using Wildcard on Workbooks.Open
 
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"

Jake Marx[_3_]

Using Wildcard on Workbooks.Open
 
Hi Stever,

Stever wrote:
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]




All times are GMT +1. The time now is 03:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com