Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Protect Chart Sheet

I have a macro that protects all the worksheets in a workbook, but not the
chart sheets. I need for it to protect them as well. Can anyone help? Here is
the code I use to protect the worksheets and workbook:

Application.ScreenUpdating = False

Dim password As String

password = Application.InputBox(prompt:="What Password Do You Want To Use?",
Type:=2)
If password = "" Then
'do nothing
Else
For Each ws In Worksheets
ws.Activate
ActiveSheet.Protect (password)
Next ws
End If

Application.ThisWorkbook.Protect (password), structu=True
Worksheets("Global & Monthly Inputs").Activate
Range("A1").Select
Application.ScreenUpdating = True

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Protect Chart Sheet

Try turning on the macro recorder and perform the action manually.

When I do that, I get:

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

so you could do

dim ws as Object

for each ws in Sheets
ws.Activate
Activesheet.protect password
Next


--
Regards,
Tom Ogilvy


"David" wrote:

I have a macro that protects all the worksheets in a workbook, but not the
chart sheets. I need for it to protect them as well. Can anyone help? Here is
the code I use to protect the worksheets and workbook:

Application.ScreenUpdating = False

Dim password As String

password = Application.InputBox(prompt:="What Password Do You Want To Use?",
Type:=2)
If password = "" Then
'do nothing
Else
For Each ws In Worksheets
ws.Activate
ActiveSheet.Protect (password)
Next ws
End If

Application.ThisWorkbook.Protect (password), structu=True
Worksheets("Global & Monthly Inputs").Activate
Range("A1").Select
Application.ScreenUpdating = True

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Protect Chart Sheet

I have three different workbooks that I use this code on, all having
different sheet names so the first option is out.
I tried the Dim ws as Object, and that did not fix the problem either. It
looks like there is a different Protect form that comes up with Chart Sheets.
Somehow, there must be a way to address a ChartSheet like WS is for
Worksheet. Still stumped!

David

"Tom Ogilvy" wrote:

Try turning on the macro recorder and perform the action manually.

When I do that, I get:

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

so you could do

dim ws as Object

for each ws in Sheets
ws.Activate
Activesheet.protect password
Next


--
Regards,
Tom Ogilvy


"David" wrote:

I have a macro that protects all the worksheets in a workbook, but not the
chart sheets. I need for it to protect them as well. Can anyone help? Here is
the code I use to protect the worksheets and workbook:

Application.ScreenUpdating = False

Dim password As String

password = Application.InputBox(prompt:="What Password Do You Want To Use?",
Type:=2)
If password = "" Then
'do nothing
Else
For Each ws In Worksheets
ws.Activate
ActiveSheet.Protect (password)
Next ws
End If

Application.ThisWorkbook.Protect (password), structu=True
Worksheets("Global & Monthly Inputs").Activate
Range("A1").Select
Application.ScreenUpdating = True

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Protect Chart Sheet

Did you notice that Tom used this:

for each ws in Sheets


You may want to post your current code if you have trouble.

David wrote:

I have three different workbooks that I use this code on, all having
different sheet names so the first option is out.
I tried the Dim ws as Object, and that did not fix the problem either. It
looks like there is a different Protect form that comes up with Chart Sheets.
Somehow, there must be a way to address a ChartSheet like WS is for
Worksheet. Still stumped!

David

"Tom Ogilvy" wrote:

Try turning on the macro recorder and perform the action manually.

When I do that, I get:

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

so you could do

dim ws as Object

for each ws in Sheets
ws.Activate
Activesheet.protect password
Next


--
Regards,
Tom Ogilvy


"David" wrote:

I have a macro that protects all the worksheets in a workbook, but not the
chart sheets. I need for it to protect them as well. Can anyone help? Here is
the code I use to protect the worksheets and workbook:

Application.ScreenUpdating = False

Dim password As String

password = Application.InputBox(prompt:="What Password Do You Want To Use?",
Type:=2)
If password = "" Then
'do nothing
Else
For Each ws In Worksheets
ws.Activate
ActiveSheet.Protect (password)
Next ws
End If

Application.ThisWorkbook.Protect (password), structu=True
Worksheets("Global & Monthly Inputs").Activate
Range("A1").Select
Application.ScreenUpdating = True

Thanks!


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Protect Chart Sheet

Thanks to each of you. I did not change my WorkSheets to Sheets. This was the
problem. Thanks again!

"Dave Peterson" wrote:

Did you notice that Tom used this:

for each ws in Sheets


You may want to post your current code if you have trouble.

David wrote:

I have three different workbooks that I use this code on, all having
different sheet names so the first option is out.
I tried the Dim ws as Object, and that did not fix the problem either. It
looks like there is a different Protect form that comes up with Chart Sheets.
Somehow, there must be a way to address a ChartSheet like WS is for
Worksheet. Still stumped!

David

"Tom Ogilvy" wrote:

Try turning on the macro recorder and perform the action manually.

When I do that, I get:

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

so you could do

dim ws as Object

for each ws in Sheets
ws.Activate
Activesheet.protect password
Next


--
Regards,
Tom Ogilvy


"David" wrote:

I have a macro that protects all the worksheets in a workbook, but not the
chart sheets. I need for it to protect them as well. Can anyone help? Here is
the code I use to protect the worksheets and workbook:

Application.ScreenUpdating = False

Dim password As String

password = Application.InputBox(prompt:="What Password Do You Want To Use?",
Type:=2)
If password = "" Then
'do nothing
Else
For Each ws In Worksheets
ws.Activate
ActiveSheet.Protect (password)
Next ws
End If

Application.ThisWorkbook.Protect (password), structu=True
Worksheets("Global & Monthly Inputs").Activate
Range("A1").Select
Application.ScreenUpdating = True

Thanks!


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Protect Chart Sheet

Well geez....that's weird...now one of the worksheets will not unprotect when
I use sheets instead of worksheets. Runtime error 1004, password is wrong,
but it is right and works manually. I change the code back to worksheets and
it works fine. The worksheet is graphs and lookup tables for specific
accounts and time periods.
Maybe I could do one run through all the worksheets and then another for
sheets(charts). Ever seen anything like this?
Here is all my code:

Sub ProtectAllSheets()
'
' ProtectAllSheets Macro
' Macro recorded 12/11/2005 by David L Perkins
'
' Keyboard Shortcut: Ctrl+p
'
Application.ScreenUpdating = False

Dim password As String
Dim ws As Object

password = Application.InputBox(prompt:="What Password Do You Want To Use?",
Type:=2)
If password = "" Then
'do nothing
Else
For Each ws In Sheets
ws.Activate
ActiveSheet.Protect (password)
Next ws
End If

Application.ThisWorkbook.Protect (password), structu=True
Worksheets("Global & Monthly Inputs").Activate
Range("A1").Select
Application.ScreenUpdating = True

End Sub

Sub UnprotectAllSheets()
'
' UnprotectAllSheets Macro
' Macro recorded 12/11/2005 by David L Perkins
'
' Keyboard Shortcut: Ctrl+u
'
Application.ScreenUpdating = False

Dim password As String
Dim ws As Object

password = Application.InputBox(prompt:="What Is The Password?", Type:=2)

Application.ThisWorkbook.Unprotect (password)

If password = "" Then
'do nothing
Else

For Each ws In Sheets
ws.Activate
ActiveSheet.Unprotect (password)
Next ws
End If

Worksheets("Global & Monthly Inputs").Activate
Range("A1").Select

Application.ScreenUpdating = True

End Sub

Thanks for the help!

"Dave Peterson" wrote:

Did you notice that Tom used this:

for each ws in Sheets


You may want to post your current code if you have trouble.

David wrote:

I have three different workbooks that I use this code on, all having
different sheet names so the first option is out.
I tried the Dim ws as Object, and that did not fix the problem either. It
looks like there is a different Protect form that comes up with Chart Sheets.
Somehow, there must be a way to address a ChartSheet like WS is for
Worksheet. Still stumped!

David

"Tom Ogilvy" wrote:

Try turning on the macro recorder and perform the action manually.

When I do that, I get:

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

so you could do

dim ws as Object

for each ws in Sheets
ws.Activate
Activesheet.protect password
Next


--
Regards,
Tom Ogilvy


"David" wrote:

I have a macro that protects all the worksheets in a workbook, but not the
chart sheets. I need for it to protect them as well. Can anyone help? Here is
the code I use to protect the worksheets and workbook:

Application.ScreenUpdating = False

Dim password As String

password = Application.InputBox(prompt:="What Password Do You Want To Use?",
Type:=2)
If password = "" Then
'do nothing
Else
For Each ws In Worksheets
ws.Activate
ActiveSheet.Protect (password)
Next ws
End If

Application.ThisWorkbook.Protect (password), structu=True
Worksheets("Global & Monthly Inputs").Activate
Range("A1").Select
Application.ScreenUpdating = True

Thanks!


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Protect Chart Sheet

I found the problem. When using sheets, it looks at HIDDEN worksheets as
well, and there was one hidden that did not have the proper password.

Thanks much again!

David

"Dave Peterson" wrote:

Did you notice that Tom used this:

for each ws in Sheets


You may want to post your current code if you have trouble.

David wrote:

I have three different workbooks that I use this code on, all having
different sheet names so the first option is out.
I tried the Dim ws as Object, and that did not fix the problem either. It
looks like there is a different Protect form that comes up with Chart Sheets.
Somehow, there must be a way to address a ChartSheet like WS is for
Worksheet. Still stumped!

David

"Tom Ogilvy" wrote:

Try turning on the macro recorder and perform the action manually.

When I do that, I get:

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

so you could do

dim ws as Object

for each ws in Sheets
ws.Activate
Activesheet.protect password
Next


--
Regards,
Tom Ogilvy


"David" wrote:

I have a macro that protects all the worksheets in a workbook, but not the
chart sheets. I need for it to protect them as well. Can anyone help? Here is
the code I use to protect the worksheets and workbook:

Application.ScreenUpdating = False

Dim password As String

password = Application.InputBox(prompt:="What Password Do You Want To Use?",
Type:=2)
If password = "" Then
'do nothing
Else
For Each ws In Worksheets
ws.Activate
ActiveSheet.Protect (password)
Next ws
End If

Application.ThisWorkbook.Protect (password), structu=True
Worksheets("Global & Monthly Inputs").Activate
Range("A1").Select
Application.ScreenUpdating = True

Thanks!


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
protect sheet enyaw Excel Programming 2 August 17th 06 10:33 AM
Protect Workbook Vs Protect Sheet Poor_pakistani New Users to Excel 4 May 25th 06 02:06 PM
Can I protect columns w/in a "List" using Protect Sheet? Diane Excel Discussion (Misc queries) 0 May 10th 06 03:30 PM
Lock and protect cells without protect the sheet Christian[_7_] Excel Programming 6 December 28th 04 04:50 PM
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet arunjoshi[_5_] Excel Programming 1 May 2nd 04 03:50 PM


All times are GMT +1. The time now is 09:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"