Any particular reason this works once but not twice?

Patience

Active Member
Joined
Mar 30, 2006
Messages
275
Hey all, little question - I have this : (Nice and easy)

Code:
Private Sub Workbook_Open()

    If ActiveWindow.Visible = False Then
        
        Exit Sub
        
        Else
    
        ActiveWindow.Visible = False
        
    End If
    
    
End Sub

in two workbooks that are in the XLStart folder. One workbook opens fine and hides, (which I want) but the other (and always the same one) gives me this:

Run Time Error 91 Object Variable or With Variable not set

I assume that it doesn't like having two things doing the same thing. Is there a way round this - just to have two workbooks open and hide (or be hidden)? Thanks.




Edit - OK - I see that ActiveWorkbook is causing problems, but ThisWorkbook.Visible doesn't exist. **** I hate this.
 
Last edited:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
If you had no visible workbooks, would there be an activewindow? :)
Can't you just hide and save the workbooks? Then they will open hidden by default.
 
Upvote 0
You see I have this disease. I means I have to try and make everything 10 times harder than it really needs to be.

Thank you Rory. :)
 
Upvote 0
I'm lucky - I'm a bit simple, so I tend to think that way! :biggrin:
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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