Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 386
Default Simple workbook Protect

morning,

could some-one please give me a very simple code for unprotecting and then
reprotecting an entire workbook (it contains three sheets)? I am looking for
a code to replace the protect sheet version of

Sheets("UP4 Données").Unprotect Password:="ABCDEFGH"

to the workbook version.

I have other code driven by macro buttons which I will put in between the
unprotect and protect codes just for reference.

Thanks
LiAD
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Simple workbook Protect

Sub ProtectAllSheets()
For Each Shts In ThisWorkbook.Worksheets
Shts.Protect Password:="ABCDEFGH"
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"LiAD" wrote:

morning,

could some-one please give me a very simple code for unprotecting and then
reprotecting an entire workbook (it contains three sheets)? I am looking for
a code to replace the protect sheet version of

Sheets("UP4 Données").Unprotect Password:="ABCDEFGH"

to the workbook version.

I have other code driven by macro buttons which I will put in between the
unprotect and protect codes just for reference.

Thanks
LiAD

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 386
Default Simple workbook Protect

Hi,

Thanks for your help again.

I have pasted the protect macro into a save maro and also a calculation
macro. It works well with the save one but not with the calculation one.
Would you know why?

The line it points to as faulting is - Range("J38").Value =
Range("J38").Value - 1

The full macro is below.

Thankyou

Sub UtiliséBobine15()

For Each Shts In ThisWorkbook.Worksheets
Shts.Unprotect Password:="ABCDEFG"
Next

Call AddToLog("UtiliséBobine15")

With Sheet1 ' Changer to suit
If Range("J38").Value < "" Then ' Change J38 to suit
Range("J38").Value = Range("J38").Value - 1
End If
End With
For Each Shts In ThisWorkbook.Worksheets
Shts.Protect Password:="ABCDEFG"
Next
End Sub

Sub AddToLog(MacName As String)

For Each Shts In ThisWorkbook.Worksheets
Shts.Unprotect Password:="ABCDEFG"
Next

Dim NextRow As Long

With Worksheets("Log")
NextRow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
.Cells(NextRow, "A").Value = MacName
.Cells(NextRow, "B").Value = Now
End With

For Each Shts In ThisWorkbook.Worksheets
Shts.Protect Password:="ABCDEFG"
Next

End Sub

"Jacob Skaria" wrote:

Sub ProtectAllSheets()
For Each Shts In ThisWorkbook.Worksheets
Shts.Protect Password:="ABCDEFGH"
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"LiAD" wrote:

morning,

could some-one please give me a very simple code for unprotecting and then
reprotecting an entire workbook (it contains three sheets)? I am looking for
a code to replace the protect sheet version of

Sheets("UP4 Données").Unprotect Password:="ABCDEFGH"

to the workbook version.

I have other code driven by macro buttons which I will put in between the
unprotect and protect codes just for reference.

Thanks
LiAD

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
Can protect worksheet then workbook but not Protect and Share in code [email protected] Excel Programming 7 January 16th 17 07:01 AM
Urgent - Simple Workbook Protect LiAD Excel Discussion (Misc queries) 1 April 9th 09 12:12 AM
Protect Workbook Vs Protect Sheet Poor_pakistani New Users to Excel 4 May 25th 06 02:06 PM
Disable Tools, Protect, Protect Workbook Paul Moles Excel Programming 1 September 5th 05 03:37 PM
Running a macro to protect a workbook on a already protected workbook UNprotects the workbook ?? WimR Excel Programming 9 July 25th 05 12:44 PM


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