Open Workbook error

  • Thread starter Thread starter alexrs2k
  • Start date Start date
A

alexrs2k

Hi.
I need to open a Workbook that starts with "Reg" but the instruction I
created gives me an error (the wild card doesn't work):

Set wbReg = Workbooks.Open(ThisWorkbook.Path & "\Reg*.xls")

Any suggestions?
 
Try

Dim strFile As String
strFile = Dir(ActiveWorkbook.Path & "\bond*.xl*", vbNormal)
Do While strFile <> ""
Set wbReg = Workbooks.Open(ActiveWorkbook.Path & "\" & strFile)
Exit Do
Loop

If this post helps click Yes
 
This should do...

Dim strFile As String
strFile = Dir(ActiveWorkbook.Path & "\Reg*.xl*", vbNormal)
If strFile <> "" Then
Set wbReg = Workbooks.Open(ActiveWorkbook.Path & "\" & strFile)
End If

If this post helps click Yes
 

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