Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Password protecting sheets through VBA

I want to password protect a spreadsheet / sheets but need to be able to
unprotect them to manipulate them via a macro. Is this possible? The
password option does not appear to be available in the protect method. Cheers
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Password protecting sheets through VBA

Use the UserInterfaceOnly flag of the Protect method. This
prevents the user from modifying the sheet, but allows VBA to do
anything. This property is not saved with the workbook, so you
should protect the sheet(s) in the Workbook_Open event. E.g.,


Private Sub Workbook_Open()
Worksheets("Sheet1").Protect Password:="abc",
userinterfaceonly:=True
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Eithne R" wrote in message
...
I want to password protect a spreadsheet / sheets but need to be
able to
unprotect them to manipulate them via a macro. Is this
possible? The
password option does not appear to be available in the protect
method. Cheers



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Password protecting sheets through VBA

Yes it is available

ActiveSheet.Protect Password:="Ron"

ActiveSheet.Unprotect Password:="Ron"


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Eithne R" wrote in message ...
I want to password protect a spreadsheet / sheets but need to be able to
unprotect them to manipulate them via a macro. Is this possible? The
password option does not appear to be available in the protect method. Cheers



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 protecting sheets in a workbook Les[_2_] Excel Worksheet Functions 4 February 24th 07 06:38 PM
Password Protecting Sheets in Excel So Others Can't See Certain Sh _ian2006_ Excel Worksheet Functions 3 February 23rd 06 05:38 PM
Password Protecting Nick Excel Discussion (Misc queries) 6 June 30th 05 12:06 PM
Protecting buttons with VB code rather than protecting sheets/books? StargateFanFromWork Excel Programming 2 July 16th 04 04:03 PM
Protecting Multiple sheets with prompt for password to unprotect pkley Excel Programming 1 January 10th 04 06:46 AM


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