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

I habe the following code that is called in the workbook open event. I can
run this in Excel 2000 without any problems but when I try to run it at work
with Excel 2002 I get an error saying the password is not correct. Debug
takes me the first line of the code below. I tried changing to "taylor" but
that didn't help. Any help on where I am going wrong would be greatly
appreciated.

If I set the password without quotes, you can't go to tools-protection and
type in the password to unprotect even if you know what it is. I assume this
is because the password is set as a variable. Do I have this wrong? Is this
where my trouble stems from?

Private Sub ProtectAll()
Sheet1.Protect Contents:=True, password:=taylor, userinterfaceonly:=True
Sheet2.Protect Contents:=True, password:=taylor, userinterfaceonly:=True
Sheet3.Protect Contents:=True, password:=taylor, userinterfaceonly:=True
Sheet4.Protect Contents:=True, password:=taylor, userinterfaceonly:=True
Sheet5.Protect Contents:=True, password:=taylor, userinterfaceonly:=True

With Sheet2.Range("b2,c24,c46,c68,c90,c112,c134")
.NumberFormat = "m/d/yy"
End With

With Sheet3.Range("c2,c24,c46,c68,c90")
.NumberFormat = "m/d/yy"
End With

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default password protection

xl2002 got more stringent.

You have to match the existing password exactly when you protect the worksheet.
I'm guessing that if you manually change the password of each sheet to taylor
(and change the code to "taylor"), it'll work ok.


Christy wrote:

I habe the following code that is called in the workbook open event. I can
run this in Excel 2000 without any problems but when I try to run it at work
with Excel 2002 I get an error saying the password is not correct. Debug
takes me the first line of the code below. I tried changing to "taylor" but
that didn't help. Any help on where I am going wrong would be greatly
appreciated.

If I set the password without quotes, you can't go to tools-protection and
type in the password to unprotect even if you know what it is. I assume this
is because the password is set as a variable. Do I have this wrong? Is this
where my trouble stems from?

Private Sub ProtectAll()
Sheet1.Protect Contents:=True, password:=taylor, userinterfaceonly:=True
Sheet2.Protect Contents:=True, password:=taylor, userinterfaceonly:=True
Sheet3.Protect Contents:=True, password:=taylor, userinterfaceonly:=True
Sheet4.Protect Contents:=True, password:=taylor, userinterfaceonly:=True
Sheet5.Protect Contents:=True, password:=taylor, userinterfaceonly:=True

With Sheet2.Range("b2,c24,c46,c68,c90,c112,c134")
.NumberFormat = "m/d/yy"
End With

With Sheet3.Range("c2,c24,c46,c68,c90")
.NumberFormat = "m/d/yy"
End With

End Sub


--

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
Password protection in macro ( Anybody can view my password in VB Sherees Excel Discussion (Misc queries) 2 January 24th 10 10:05 PM
Excel Data Protection- AKA: Sheet/Macro Password Protection Mushman(Woof!) Setting up and Configuration of Excel 0 December 29th 09 06:50 AM
Password Protection Kiley Excel Discussion (Misc queries) 7 October 8th 09 02:25 PM
PASSWORD PROTECTION JFW Excel Worksheet Functions 3 January 2nd 09 10:44 PM
Password Protection DNA Excel Discussion (Misc queries) 0 May 3rd 06 01:59 PM


All times are GMT +1. The time now is 12:52 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"