ChrisDaniels
New Member
- Joined
- Jul 1, 2011
- Messages
- 8
Hi all
This is really foxing me and I'm hoping someone can help before I pull all my hair out!
In 2013/2016 creating a new workbook will leave the focus on ThisWorkbook even though it is the ActiveWorkbook, and I cannot seem to get around it.
The reason this is causing an issue is that in several tools that I maintain, they will spring off new workbooks if the user clicks a button to do so.
If the user wants to then save this new book or close it, it will save the original book or close the original book as the background focus is still on the original book!
I know its something to do with the new SDI that Microsoft built in from 2013, but I cannot figure out how to work around it for new workbooks - the only help MS seem to offer relates to userforms.
Example code to replicate:
Then immediately go to Save As and note the filename in the prompt, or Close using the top right cross and note the filename in the prompt there.
This is really foxing me and I'm hoping someone can help before I pull all my hair out!
In 2013/2016 creating a new workbook will leave the focus on ThisWorkbook even though it is the ActiveWorkbook, and I cannot seem to get around it.
The reason this is causing an issue is that in several tools that I maintain, they will spring off new workbooks if the user clicks a button to do so.
If the user wants to then save this new book or close it, it will save the original book or close the original book as the background focus is still on the original book!
I know its something to do with the new SDI that Microsoft built in from 2013, but I cannot figure out how to work around it for new workbooks - the only help MS seem to offer relates to userforms.
Example code to replicate:
Code:
Sub TestCreateNewBook()
Dim NewBook As Workbook
Set NewBook = Workbooks.Add
NewBook.ActiveSheet.Activate
Set NewBook = Nothing
End sub
Then immediately go to Save As and note the filename in the prompt, or Close using the top right cross and note the filename in the prompt there.
Last edited: