Problem with ".Visible" sheet property

R

Robert Crandal

When someone initially opens a workbook, the "Workbook_Open"
subroutine is immediately executed. Here are the first few lines of the
Workbook_Open() subroutine:

Sheet15.Visible = xlVeryHidden
Sheet16.Visible = xlVeryHidden
Sheet17.Visible = xlVeryHidden
Sheet18.Visible = xlVeryHidden

This code is executed just to ensure that sheets 15 through 18
are always hidden, even if the sheets are already hidden.

So far, this code has never failed or ever caused any problems
at all.....until NOW!

One of my users seems to have accidentally created a situation
where the above code will immediately crash at the first
line "Sheet15.Visible = xlVeryHidden" and I have no idea
why this is happening. The above code works fine on everybody
else's workbooks, but how could the code NOT be working
for just one user???? Are there any Excel settings or buttons
that the user might have pressed which could be causing this???
Is there any way I could fix this??

BTW, the error message which occurred states "Method 'Visible'
of object Worksheet failed".

thank you
 
P

Per Jessen

Hi

Check if the workbook has been protected, as a protected workbook will cause
this error.

Hopes this helps.
....
Per
 
R

Ryan H

Is the workbook on a network server drive or is it saved locally on
individuals computers? If it's saved locally, it seems to me that the user
has protected the workbook. You could manually unprotect Put this code in
the Workbook Open Event. This code will unprotect the workbook, hide the
sheets, then unprotect the workbook. Hope this helps! If so, let me know,
click "YES" below.

Private Sub Workbook_Open()

With ThisWorkbook
.Unprotect "Your Password Here"
.Sheets("Sheet15").Visible = xlVeryHidden
.Sheets("Sheet16").Visible = xlVeryHidden
.Sheets("Sheet17").Visible = xlVeryHidden
.Sheets("Sheet18").Visible = xlVeryHidden
.Protect "Your Password Here"
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top