'Workbooks.Open' doesn't open workbook! (!??)

Randall00

Board Regular
Joined
Jan 31, 2008
Messages
54
Hey everybody,

Am I missing something here, or should this be working:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Dim strPath As String
    strPath = ThisWorkbook.Path & "\core.xlsb"

Dim wbCORE As Workbook
Set wbCORE = Workbooks.Open(strPath)

End Sub

I'm just trying to get this workbook to open up another workbook--I'm fairly certain I've gotten this to work just fine many many times before. Should this code not open up the "core.xlsb" workbook?? (which definitely does exist, is spelled correctly and is located in the same directory as "ThisWorkbook")?

It seems to ignore the Workbooks.Open statement as though it's not even there. ThisWorkbook's window is not visible, but it doesn't seem to make a difference whether I leave it visible or not.

What could be going on here?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi Randall00,

Try:

Code:
Workbooks.Open(strPath)

Instead of:

Code:
Dim wbCORE As Workbook
Set wbCORE = Workbooks.Open(strPath)
 
Upvote 0
Try
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Workbooks.Open(ThisWorkbook.Path & "\core.xlsb")
 
End Sub

- Make sure you've saved the file first and then close to open up core.xlsb.
- Make sure core has the extension of xlsb
 
Upvote 0
Hmm, nope, no good. It is an Option Explicit document. I took that out and tried it anyway, but it doesn't open the workbook like it should. :\

Thanks kpark--I've tried a lot of these variations and continue to yield the same result. But in theory, shouldn't the code I have posted to begin with work perfectly fine?
 
Last edited:
Upvote 0
I don't really trust the VBA anymore :\
I try to declare all the variables I can with more basic datatypes (long, int, string, etc..) or try not using variables at all if not needed.

But yes, the code you've posted should have worked perfectly fine. as it did on mine..
 
Upvote 0
Well that's a relief anyway. At least I'm not losing my mind.

I'll give it a restart or something I guess.
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top