Return Workbook to a visible state

julhs

Active Member
Joined
Dec 3, 2018
Messages
471
Office Version
  1. 2010
Platform
  1. Windows
I hope someone can help me, I’ve stuffed up!!!!!!!
I have/had the below code in the Primary workbook (in it’s “This Workbook” module) with the intention of auto open a secondary workbook in a “Mininized” state.
VBA Code:
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Workbooks.Open "C:\Users\***\Documents\My Documents\****.xlsm", False
ActiveWindow.Visible = False
Application.ScreenUpdating = True
End Sub
Big problem now is that when I open the secondary workbook (by whatever means), it opens it to the image added.
Snip image
Blank Excel Window Capture.JPG
When secondary workbook opens; Project explorer lists all the sheets in the workbook, as you would expect.
But, I simply can’t view the workbook with all the sheets.

I pray this is fixable as I have committed the cardinal rule of NOT ensuring I have a resent backup copy!!!!!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
If you edit your code to change the visible property back to True, does it help?

VBA Code:
ActiveWindow.Visible = True
 
Upvote 0
Thanks for your response.
Tried doing that in the “Secondary” workbook “This Workbook” module but with no joy.
Let me try doing that in the “Primary” workbook “This Workbook” module immediately after where I used
Rich (BB code):
Workbooks.Open "C:\Users\***\Documents\My Documents\****.xlsm", False
 
Upvote 0
Try this:
VBA Code:
Sub MakeAllVisible()
Dim wb As Workbook
For Each wb In Workbooks
    wb.Windows(1).Visible = True
Next wb
End Sub
 
Upvote 0
You can easily unhide it via the Ribbon, View > Unhide.
You will then want to save it in the Unhidden state but if you don't remove the line that hides it in the Open Event it will just hide again the next time you open it.

1701414569630.png
 
Upvote 0
Thank you Riv01 & Skyybot for your responses.
Big relief!!
In the “Primary” workbook I substituted
VBA Code:
ActiveWindow.Visible = False
for
VBA Code:
ActiveWindow.Visible = True
At least then “Secondary” Workbook opened to the visible state that you would expect
What I have learnt from this is:
VBA Code:
ActiveWindow.Visible = False
actually “HIDES” the secondary workbook and doesn’t just open it in a “Minimised” state in the same
way that clicking on the “Minimise” button in top right of a sheet does.
Also in my panic I missed the fact that I could simply use “Unhide” in the “Secondary” workbook (so “View” tab > “Window” section & click “Unhide”) once I had closed the “Primary” one
As I don’t like the effects of using ActiveWindow.Visible = False
I was wondering if I left it out of the Workbook_Open() code in the “Primary” book and then after the “Secondary” has opened, set the “Primary” book to be the ActiveSheet/Book?
Something along these lines:-
VBA Code:
Private Sub Workbook_Open()
Workbooks.Open "C:\Users\***\Documents\My Documents\****.xlsm", False
'Activate "Primary" Workbook.xlsm
End Sub
 
Upvote 0
Thanks Alex
Apologies, I have caused the post to be out of sync.

As you can see to my reply to Riv01 & Skyybot I did figure out the "Unhide" of the "Secondary"
I did start to play around with using;
VBA Code:
ActiveWindow.WindowState = xlMinimized
But left off it and went into panic mode when I couldn’t see the "Secondary" book worksheets
I'll try your suggestion later as have to go out for rest of day
 
Upvote 0
Been experimenting with things.
Only you guys can tell me why this sort of works!?
While the below gets me 80% of what I wanting to achieve, there is still the other 20%!!
Below gives me 2 images in the task bar of the “Primary”
VBA Code:
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False
Workbooks.Open "C:\Users\**** \My Documents\******.xlsm"
ActiveWindow.WindowState = xlMinimized
ActiveWindow.WindowState = xlMaximized
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = True
End Sub
But problem is with the remaining 20%
Having run the above code.
Firstly;
In the task bar there are 2 windows showing the same “Primary” workbook , BUT not the “Primary” and “Secondary”.
IF I subsequently click on the 1st image of the “Primary”, then that is displayed as you’d expect.
If I then click on the 2nd image of the “Primary” in the task bar, THEN the “Secondary” book is displayed in the task bar as you would expect.
But believe there is some sort of direct correlation to “Project Explorer” showing both the “Primary” and the “Secondary” in a collapsed state???
Secondarily,
NONE of the Application Events do anthing to prevent all the screen flicker.
This is way over my my head, so any suggestions you guys can make are gratefully received
 
Upvote 0
Neglected to mention a key point, that using :-
VBA Code:
ActiveWindow.WindowState = xlMinimized
ActiveWindow.WindowState = xlMaximized
Resulted in the “Primary” book being the "Active Visible" book WITHOUT the need to do anything else
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

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