Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 553
Default How to unprotect a workbook by macro?

HELP! HELP! HELP!
I have a workbook with its structure locked. How to unprotect a workbook by
macro?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default How to unprotect a workbook by macro?

for worksheets without a password:

Sub UnlockSheet()
Worksheets('sheetname').Unprotect
End Sub

or if it has password

Sub UnlockSheet()
Worksheet('sheetname').Unprotect password:="password"
End Sub

"FARAZ QURESHI" wrote:

HELP! HELP! HELP!
I have a workbook with its structure locked. How to unprotect a workbook by
macro?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default How to unprotect a workbook by macro?

Oops - you said workBOOK, not workSHEET.

Use ActiveWorkbook.Unprotect instead of Worksheets('sheetname').Unprotect




"FARAZ QURESHI" wrote:

HELP! HELP! HELP!
I have a workbook with its structure locked. How to unprotect a workbook by
macro?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 553
Default How to unprotect a workbook by macro?

THANX PAL!
I REALLY APPRECIATE!
CAN U ALSO NOTIFY ME SOME CODE RESTRICTING INSERTION/DELETION, OR CHANGING
SIZE OF, ANY COLUMN/ROW?
THANX AGAIN!

"JLatham" wrote:

Oops - you said workBOOK, not workSHEET.

Use ActiveWorkbook.Unprotect instead of Worksheets('sheetname').Unprotect




"FARAZ QURESHI" wrote:

HELP! HELP! HELP!
I have a workbook with its structure locked. How to unprotect a workbook by
macro?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default How to unprotect a workbook by macro?

This code will protect a worksheet from change:

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

if you wish to add password protection to that, then:

ActiveSheet.Protect Password:="password", _
DrawingObjects:=True, _
Contents:=True, Scenarios:=True

To unprotect, it is either
ActiveSheet.Unprotect
when there is no password associated with the protection, or
ActiveSheet.Unprotect Password:="password"
when there is a password given. The passwords have to match.

You can only protect/unprotect a single sheet at a time, but if you wish to
do all sheets in a workbook at once:

Sub ProtectOrUnprotect()
Dim anySheet As Worksheet

For Each anySheet in Worksheets
'... put protect or unprotect code here using anySheet instead of
ActiveSheet
' example of unprotecting:
anySheet.Unprotect password:="FARAZ"
Next
End Sub


"FARAZ QURESHI" wrote:

THANX PAL!
I REALLY APPRECIATE!
CAN U ALSO NOTIFY ME SOME CODE RESTRICTING INSERTION/DELETION, OR CHANGING
SIZE OF, ANY COLUMN/ROW?
THANX AGAIN!

"JLatham" wrote:

Oops - you said workBOOK, not workSHEET.

Use ActiveWorkbook.Unprotect instead of Worksheets('sheetname').Unprotect




"FARAZ QURESHI" wrote:

HELP! HELP! HELP!
I have a workbook with its structure locked. How to unprotect a workbook by
macro?

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
Sign a workbook contains macro Sevgi Excel Discussion (Misc queries) 0 November 8th 06 07:50 AM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
How can I get a validation to run in a macro on a shared workbook? arewa Excel Discussion (Misc queries) 3 January 2nd 06 11:31 PM
Protect Workbook vs Worksheet?? Dan B Excel Worksheet Functions 3 November 7th 05 09:02 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM


All times are GMT +1. The time now is 11:51 PM.

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"