PC Review


Reply
Thread Tools Rate Thread

applying worksbook protection via a Macro

 
 
=?Utf-8?B?RGF2aWQgUw==?=
Guest
Posts: n/a
 
      19th Mar 2007
Can an one tell me how to record a macro that will un-password protect a
workbook then hide several worksheets then re-password protect the workbook?
 
Reply With Quote
 
 
 
 
Corey
Guest
Posts: n/a
 
      19th Mar 2007
Sub ProtectWkbandHideSheets()

ActiveWorkbook.Unprotect Password = "123"
Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Visible = False
Sheets("Sheet3").Select
ActiveWindow.SelectedSheets.Visible = False
ActiveWorkbook.Protect Password = "123"
End Sub

Change sheets and P/W to suit.

Corey....
"David S" <David (E-Mail Removed)> wrote in message
news:538F857B-393B-4828-BC1D-(E-Mail Removed)...
Can an one tell me how to record a macro that will un-password protect a
workbook then hide several worksheets then re-password protect the workbook?


 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      19th Mar 2007
Here's one already built.

Sub hide_em()
ActiveWorkbook.Unprotect Password:="justme"
Worksheets(Array("sheet1", "Sheet3", _
"Sheet5")).Visible = False
ActiveWorkbook.Protect Password:="justme", Structure:=True, Windows:=True
End Sub

If you were to record doing this your code would look like so..........

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 03-19-2007 by Gord Dibben
'
ActiveWorkbook.Unprotect
Sheets(Array("Sheet1", "Sheet3", "Sheet5")).Select
ActiveWindow.SelectedSheets.Visible = False
ActiveWorkbook.Protect Structure:=True, Windows:=True
End Sub


Notice that no password is recorded so you have to add it as the hide_em sub
does.


Gord Dibben MS Excel MVP

On Mon, 19 Mar 2007 13:36:10 -0700, David S <David (E-Mail Removed)>
wrote:

>Can an one tell me how to record a macro that will un-password protect a
>workbook then hide several worksheets then re-password protect the workbook?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
populate nonblank cells from worksbook to another Dave H Microsoft Excel Worksheet Functions 2 17th Dec 2008 05:21 AM
Applying Protection Perameters With VBA Code scott@utahpavers.com Microsoft Excel Programming 1 30th Jan 2007 09:47 PM
Applying Protection To Multiple Sheets Mhz Microsoft Excel New Users 4 6th Jul 2006 01:22 PM
Re: Removing and Applying protection in VBA steve Microsoft Excel Programming 2 20th Oct 2003 09:14 PM
Applying protection to an Excel Expense Report Donna Bennett Microsoft Excel Programming 1 18th Oct 2003 03:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:21 PM.