Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I can hide a single Worksheet.
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Worksheets(1).Visible = False ' Worksheets(1).Visible = True End Sub I want to hide a single Worksheet, but only when the Workbook is protected. How do I detect a protected workbook? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Try this With ActiveWorkbook IsProtected = .ProtectStructure Or .ProtectWindows End With Mike "Fan924" wrote: I can hide a single Worksheet. Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Worksheets(1).Visible = False ' Worksheets(1).Visible = True End Sub I want to hide a single Worksheet, but only when the Workbook is protected. How do I detect a protected workbook? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Worksheets(4).Visible = False
If ActiveWorkbook.ProtectStructure = False Then Worksheets(4).Visible = True End If But it doesn't work. After the workbook is protected, you are blocked from changing the sheet visiility. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
You asked how to detect if a workbook is protected and the answer I gave you does that. You must un-protect to hide the sheet then r-protect Sub Sonic() With ActiveWorkbook isprotected = .ProtectStructure Or .ProtectWindows End With If isprotected Then ActiveWorkbook.Unprotect Sheets("Sheet1").Visible = False ActiveWorkbook.Protect Exit Sub End If End Sub Mike "Fan924" wrote: Worksheets(4).Visible = False If ActiveWorkbook.ProtectStructure = False Then Worksheets(4).Visible = True End If But it doesn't work. After the workbook is protected, you are blocked from changing the sheet visiility. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Perhaps your looking for something like this
Sub Sonic() With ActiveWorkbook isprotected = .ProtectStructure Or .ProtectWindows End With If isprotected Then ActiveWorkbook.Unprotect Sheets("Sheet1").Visible = False ActiveWorkbook.Protect Structu=True Else Sheets("Sheet1").Visible = True End If End Sub Mike "Mike H" wrote: Hi, You asked how to detect if a workbook is protected and the answer I gave you does that. You must un-protect to hide the sheet then r-protect Sub Sonic() With ActiveWorkbook isprotected = .ProtectStructure Or .ProtectWindows End With If isprotected Then ActiveWorkbook.Unprotect Sheets("Sheet1").Visible = False ActiveWorkbook.Protect Exit Sub End If End Sub Mike "Fan924" wrote: Worksheets(4).Visible = False If ActiveWorkbook.ProtectStructure = False Then Worksheets(4).Visible = True End If But it doesn't work. After the workbook is protected, you are blocked from changing the sheet visiility. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Not detecting Open Workbook - Why | Excel Discussion (Misc queries) | |||
Detecting open workbook | Excel Programming | |||
Detecting the workbook name on startup | Excel Programming | |||
Detecting a another workbook has opended | Excel Programming | |||
Detecting workbook activation | Excel Programming |