Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default protect and unprotect

Hi - I am either missing something really simple or something else is
happening:

This works fine...
sub proc i_protect
Dim mySheet As Worksheet

For Each mySheet In Worksheets
mySheet.protect ("abc1234")
Next mySheet

end sub

This says the password is incorrect...
sub proc i_unprotect
Dim mySheet As Worksheet

For Each mySheet In Worksheets
mySheet.Unprotect ("abc1234")
Next mySheet

end sub

Any ideas?

Thanks

Andrew



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default protect and unprotect

In ,
Andrew wrote:
Hi - I am either missing something really simple or something else is
happening:

This works fine...
sub proc i_protect
Dim mySheet As Worksheet

For Each mySheet In Worksheets
mySheet.protect ("abc1234")
Next mySheet

end sub

This says the password is incorrect...
sub proc i_unprotect
Dim mySheet As Worksheet

For Each mySheet In Worksheets
mySheet.Unprotect ("abc1234")
Next mySheet

end sub

Any ideas?

Thanks

Andrew


Hi Andrew,

just tested it (I had to remove proc statements (what are these for?)).

Excel 2003 - works fine (protect and unprotect)

Are both procedures referring to the same workbook?

cheers,

Stephan


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default protect and unprotect

Just a guess but one of your sheets is protected with a different password.
Give this code a try...

Sub i_protect()
Dim mySheet As Worksheet

For Each mySheet In Worksheets
mySheet.Protect "abc1234"
Next mySheet

End Sub

Sub i_unprotect()
Dim mySheet As Worksheet

On Error GoTo ErrorHandler
For Each mySheet In Worksheets
mySheet.Unprotect "abc1234"
Next mySheet
Exit Sub
ErrorHandler:
MsgBox "Sheet " & mySheet.Name & " could not be unprotected.",
vbInformation
Resume Next
End Sub
--
HTH...

Jim Thomlinson


"Andrew" wrote:

Hi - I am either missing something really simple or something else is
happening:

This works fine...
sub proc i_protect
Dim mySheet As Worksheet

For Each mySheet In Worksheets
mySheet.protect ("abc1234")
Next mySheet

end sub

This says the password is incorrect...
sub proc i_unprotect
Dim mySheet As Worksheet

For Each mySheet In Worksheets
mySheet.Unprotect ("abc1234")
Next mySheet

end sub

Any ideas?

Thanks

Andrew




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, unprotect Pyrite Excel Discussion (Misc queries) 0 August 15th 08 03:18 PM
protect and unprotect Andrew[_51_] Excel Programming 1 October 13th 05 07:24 PM
Password - Protect, UnProtect MrAlMackay Excel Programming 5 January 19th 05 07:23 PM
Unprotect and protect.... Wilfrid Excel Programming 1 July 28th 04 03:13 AM
Thanks Otto.......Unprotect and re-Protect CLR Excel Programming 1 May 31st 04 06:43 AM


All times are GMT +1. The time now is 03:12 AM.

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"