Using a wildcard to open an excel workbook

We cannot open a file using a wildcard - imagine the chaos if we could!

You'll need to use Dir(ActiveWorkbook.Path & "\302113*.xlsm") to loop through the files that this returns. If there will only be one then just use this function once:

Dim sFound As String

sFound = Dir(ActiveWorkbook.Path & "\302113*.xlsm")    'the first one found
If sFound <> "" Then
    Workbooks.Open filename:= ActiveWorkbook.Path & "\" & sFound
End If

Dir Function :tech on the net


From my experience this works if you have the wildcard/asterix as the last symbol in the string and if there is only one file. Try doing:

Workbooks.Open filename:=ActiveWorkbook.Path & "\302113*"

For example I am using:

Workbooks.Open Filename:="X:\business\2014\Easy*"

and it works.