Hi, I'm relatively new to Macros and I'm running into a snag. Your help is appreciated!!
I have an Excel File with multiple sheets. Each sheet contains macros that copy / paste. I want to password protect each sheet. Because the macro copies and pastes, I needed to add code to the macro that unprotects and re-protects the sheet. This worked great for one sheet as long as the other sheets were unprotected. As soon as I protect the other sheets, I receive errors ("Unable to set the IncludeNumber property of the style class). I have included the Macro code for one of my Macros.
Does anyone have any suggestions for how I can get this to work? Thanks for the help!!
Sub PrintMachineryList()
Application.Run "Zoom60Percent"
Range("A1".Select
Range("A1:E57".Select
ActiveSheet.Unprotect ("xyz"
With ActiveWorkbook.Styles("Normal"
.IncludeNumber = False
.IncludeFont = False
.IncludeAlignment = False
.IncludeBorder = False
.IncludePatterns = True
.IncludeProtection = False
End With
Selection.Style = "Normal"
Selection.PrintOut Copies:=1, Collate:=True
Range("A100:E156".Select
Selection.Copy
Range("A1:E57".Select
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Protect ("xyz", DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("C3".Select
End Sub
I have an Excel File with multiple sheets. Each sheet contains macros that copy / paste. I want to password protect each sheet. Because the macro copies and pastes, I needed to add code to the macro that unprotects and re-protects the sheet. This worked great for one sheet as long as the other sheets were unprotected. As soon as I protect the other sheets, I receive errors ("Unable to set the IncludeNumber property of the style class). I have included the Macro code for one of my Macros.
Does anyone have any suggestions for how I can get this to work? Thanks for the help!!
Sub PrintMachineryList()
Application.Run "Zoom60Percent"
Range("A1".Select
Range("A1:E57".Select
ActiveSheet.Unprotect ("xyz"
With ActiveWorkbook.Styles("Normal"
.IncludeNumber = False
.IncludeFont = False
.IncludeAlignment = False
.IncludeBorder = False
.IncludePatterns = True
.IncludeProtection = False
End With
Selection.Style = "Normal"
Selection.PrintOut Copies:=1, Collate:=True
Range("A100:E156".Select
Selection.Copy
Range("A1:E57".Select
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Protect ("xyz", DrawingObjects:=True, Contents:=True, Scenarios:=True
Range("C3".Select
End Sub