DisgruntledVBANovice
New Member
- Joined
- Jul 8, 2020
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Hi all,
I am very much a novice VBA programmer, and I am having a hard time figuring out why Excel is doing what it is doing.
I have some code that is part of a user form. When the form opens, I open another Excel file that has the default settings for the form stored in it. After grabbing the values out of this file that I need, I then close it. What I am finding though, is that if this form is opened from a blank workbook (such as opening Excel via the start menu), then when I open the settings form, Excel is closing Book1. I have tried setting the originally open workbook to a variable (thinking that if the workbook was in a variable, Excel would not close it automatically).
If I do the same thing, but either open an existing workbook or create a blank workbook (essentially Book2), then everything works as expected (my settings file opens and closes and the original workbook is left open).
Is there something I am doing wrong or is there a way to keep Excel from closing the default Book1 when I open a different file?
Thanks!
I am very much a novice VBA programmer, and I am having a hard time figuring out why Excel is doing what it is doing.
I have some code that is part of a user form. When the form opens, I open another Excel file that has the default settings for the form stored in it. After grabbing the values out of this file that I need, I then close it. What I am finding though, is that if this form is opened from a blank workbook (such as opening Excel via the start menu), then when I open the settings form, Excel is closing Book1. I have tried setting the originally open workbook to a variable (thinking that if the workbook was in a variable, Excel would not close it automatically).
If I do the same thing, but either open an existing workbook or create a blank workbook (essentially Book2), then everything works as expected (my settings file opens and closes and the original workbook is left open).
Is there something I am doing wrong or is there a way to keep Excel from closing the default Book1 when I open a different file?
Thanks!