Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default applying worksbook protection via a Macro

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default applying worksbook protection via a Macro

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 wrote in message
...
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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default applying worksbook protection via a Macro

Here's one already built.

Sub hide_em()
ActiveWorkbook.Unprotect Password:="justme"
Worksheets(Array("sheet1", "Sheet3", _
"Sheet5")).Visible = False
ActiveWorkbook.Protect Password:="justme", Structu=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 Structu=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
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
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
populate nonblank cells from worksbook to another Dave H[_2_] Excel Worksheet Functions 2 December 17th 08 05:21 AM
Applying Protection Perameters With VBA Code [email protected] Excel Programming 1 January 30th 07 09:47 PM
Applying Protection To Multiple Sheets Mhz New Users to Excel 4 July 6th 06 01:22 PM
Removing and Applying protection in VBA steve Excel Programming 2 October 20th 03 09:14 PM
Applying protection to an Excel Expense Report Donna Bennett Excel Programming 1 October 18th 03 03:33 PM


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