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

Hi,

Is it possible to protect/unprotect a sheet with a
password in VBA?. Example please if any.

Thanks
PeteD
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protecting Sheets

Pete,

Here is a sample that I use.
At the start of the code I unprotect the sheets so the
rest of my code can run:

Sheets("Raw Data").Select
ActiveSheet.Unprotect Password:="yourpassword"
Sheets("Output Page").Select
ActiveSheet.Unprotect Password:="yourpassword"

Then I password protect the sheets again:

Sheets("Raw Data").Select
ActiveSheet.Protect DrawingObjects:=True,
Contents:=True, Scenarios:=True, Password:="yourpassword"
Sheets("Output Page").Select
ActiveSheet.Protect DrawingObjects:=True,
Contents:=True, Scenarios:=True, Password:="yourpassword"

Make sure you also password protect the code.

jill
-----Original Message-----
Hi,

Is it possible to protect/unprotect a sheet with a
password in VBA?. Example please if any.

Thanks
PeteD
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Protecting Sheets

Yes you can. Here is sample code. This uses the active
sheet but you can do a select of any sheet also.

Sub ProtectWorksheet()
ActiveSheet.Protect password:="password"
End Sub

Sub UnprotectWorksheet()
ActiveSheet.Unprotect password:="password"
End Sub

-----Original Message-----
Hi,

Is it possible to protect/unprotect a sheet with a
password in VBA?. Example please if any.

Thanks
PeteD
.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Protecting Sheets

Thanks Jill

PeteD


-----Original Message-----
Pete,

Here is a sample that I use.
At the start of the code I unprotect the sheets so the
rest of my code can run:

Sheets("Raw Data").Select
ActiveSheet.Unprotect Password:="yourpassword"
Sheets("Output Page").Select
ActiveSheet.Unprotect Password:="yourpassword"

Then I password protect the sheets again:

Sheets("Raw Data").Select
ActiveSheet.Protect DrawingObjects:=True,
Contents:=True, Scenarios:=True, Password:="yourpassword"
Sheets("Output Page").Select
ActiveSheet.Protect DrawingObjects:=True,
Contents:=True, Scenarios:=True, Password:="yourpassword"

Make sure you also password protect the code.

jill
-----Original Message-----
Hi,

Is it possible to protect/unprotect a sheet with a
password in VBA?. Example please if any.

Thanks
PeteD
.

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Protecting Sheets

Thanks Tim.

Pete



-----Original Message-----
Yes you can. Here is sample code. This uses the active
sheet but you can do a select of any sheet also.

Sub ProtectWorksheet()
ActiveSheet.Protect password:="password"
End Sub

Sub UnprotectWorksheet()
ActiveSheet.Unprotect password:="password"
End Sub

-----Original Message-----
Hi,

Is it possible to protect/unprotect a sheet with a
password in VBA?. Example please if any.

Thanks
PeteD
.



.

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
Protecting Sheets Esradekan[_2_] Excel Worksheet Functions 2 May 30th 09 11:52 PM
protecting sheets christina Excel Discussion (Misc queries) 2 May 29th 09 11:27 PM
Protecting Sheets Joyce Excel Worksheet Functions 3 March 20th 06 08:18 PM
Protecting Sheets albertmb Excel Discussion (Misc queries) 7 March 13th 06 09:13 PM
Protecting sheets TV Excel Discussion (Misc queries) 1 November 29th 04 09:27 PM


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