Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Password protection worksheet

I have a worksheet which I require to have password protected. I have set
the password up in the normal way no problem.
I then want users to be able to run a macro to select a custom view, I have
attached the following code to the macro which will allow the view to be run
without requesting a password (if the bit with password isnt in there is does
ask the user to input the password before showing the custom view).
' Sheets("sheet 2"). Unprotect Password = "mypassword"
ActiveWorkbook.CustomViews("2 - Monday View").Show
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowSorting:=True
Range("L9").Select
Sheets("sheet 2").Protect Password = "mypassword"
End Sub

However, whilst the macro appears to work it doesnt put the password back on
the worksheet. The user can just go to unprotect sheet and click on ok which
is what I need to stop.

any help would be most welcome.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Password protection worksheet

Julie,

You need the correct syntax
Sheets("sheet 2").Unprotect Password:="mypassword"


Sheets("sheet 2").Protect Password:="mypassword"

HTH,
Bernie
MS Excel MVP


"julief" wrote in message
...
I have a worksheet which I require to have password protected. I have set
the password up in the normal way no problem.
I then want users to be able to run a macro to select a custom view, I have
attached the following code to the macro which will allow the view to be run
without requesting a password (if the bit with password isnt in there is does
ask the user to input the password before showing the custom view).
' Sheets("sheet 2"). Unprotect Password = "mypassword"
ActiveWorkbook.CustomViews("2 - Monday View").Show
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowSorting:=True
Range("L9").Select
Sheets("sheet 2").Protect Password = "mypassword"
End Sub

However, whilst the macro appears to work it doesnt put the password back on
the worksheet. The user can just go to unprotect sheet and click on ok which
is what I need to stop.

any help would be most welcome.




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
Excel Worksheet Password Protection Christina Excel Worksheet Functions 2 March 19th 13 12:24 PM
Worksheet level password protection Liz Excel Programming 5 May 14th 07 07:23 PM
Password protection of worksheet when copied and pasted. Shansi Excel Worksheet Functions 1 July 30th 05 12:23 AM
Worksheet Password Protection in VBA Graham[_5_] Excel Programming 1 April 23rd 04 05:01 PM
Setting worksheet protection password in VBA Mark Bochner Excel Programming 0 October 6th 03 10:59 PM


All times are GMT +1. The time now is 08:49 AM.

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

About Us

"It's about Microsoft Excel"