Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Code to protect sheets, protects work book also?

I am trying to protect to 2 worksheets upon work book open

Code:
Private Sub Workbook_Open()
Password = "1234"
Sheets("MasterData").Visible = xlSheetVeryHidden
Sheets("MasterData").Protect Password, True, True, True
Sheets("Unassigned Requests").Protect Password, True, True, True
End Sub

This works fine and it protects the sheets.
But
1. It protects the workbook also. When i open the excel it asks for a
password, which i dont require and i am not able to remove it
2. When I supply the same password in the excel (Tools Protection
UnProtect), it does not work.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Code to protect sheets, protects work book also?

Any thoughts anyone?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Code to protect sheets, protects work book also?

You can save a file with a password that prevents others from opening the
file--or prevents them from writing over the file.

File|SaveAs|tools|general options
is where you'd specify that password (and remove it if you want)

maybe????

thiaga wrote:

I am trying to protect to 2 worksheets upon work book open

Code:
Private Sub Workbook_Open()
Password = "1234"
Sheets("MasterData").Visible = xlSheetVeryHidden
Sheets("MasterData").Protect Password, True, True, True
Sheets("Unassigned Requests").Protect Password, True, True, True
End Sub

This works fine and it protects the sheets.
But
1. It protects the workbook also. When i open the excel it asks for a
password, which i dont require and i am not able to remove it
2. When I supply the same password in the excel (Tools Protection
UnProtect), it does not work.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Code to protect sheets, protects work book also?

I dont want the password for the workbook to be set at all.
I just want the sheets to be protected.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Code to protect sheets, protects work book also?

Save the workbook as a new name without the password.
close excel

Open windows explorer.
delete the old file
rename the new file to the old name.

thiaga wrote:

I dont want the password for the workbook to be set at all.
I just want the sheets to be protected.


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Code to protect sheets, protects work book also?

Thanks Dave, this works!
But it sets the password when i close it and open again

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Code to protect sheets, protects work book also?

What password is being set when you open and close and reopen?

If you saved a copy with no password (tools|options|general options under the
File|SaveAs dialog, then you shouldn't be asked for a password.


thiaga wrote:

Thanks Dave, this works!
But it sets the password when i close it and open again


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Code to protect sheets, protects work book also?

Don't even put in a space character--just leave those boxes empty.

thiaga wrote:

Thanks Dave, this works!
But it sets the password when i close it and open again


--

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
Code to protect all the worksheets in a book bill_ball New Users to Excel 1 June 10th 10 08:06 AM
work book sheets kathy Setting up and Configuration of Excel 1 April 23rd 09 11:46 PM
One cell to many cells (two different work book/sheets) Shek5150 Excel Discussion (Misc queries) 7 August 29th 08 01:10 PM
How do I repeat XML map in sheets of the same excel work book Tooty Excel Discussion (Misc queries) 0 March 20th 08 11:10 PM
Protecting a book protects too much?! StargateFanFromWork Excel Programming 2 July 6th 04 12:52 PM


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