ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Open Workbook error (https://www.excelbanter.com/excel-discussion-misc-queries/242975-open-workbook-error.html)

alexrs2k

Open Workbook error
 
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?
--
Alex
*Remember to click "yes" if this post helped you. Thank you!


Jacob Skaria

Open Workbook error
 
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
---------------
Jacob Skaria


"alexrs2k" wrote:

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?
--
Alex
*Remember to click "yes" if this post helped you. Thank you!


Jacob Skaria

Open Workbook error
 
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
---------------
Jacob Skaria


"Jacob Skaria" wrote:

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
---------------
Jacob Skaria


"alexrs2k" wrote:

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?
--
Alex
*Remember to click "yes" if this post helped you. Thank you!


alexrs2k

Open Workbook error
 
Thank you Jacob! It works perfectly.
--
Alex
*Remember to click "yes" if this post helped you. Thank you!



"Jacob Skaria" wrote:

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
---------------
Jacob Skaria


"Jacob Skaria" wrote:

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
---------------
Jacob Skaria


"alexrs2k" wrote:

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?
--
Alex
*Remember to click "yes" if this post helped you. Thank you!



All times are GMT +1. The time now is 04:31 AM.

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