R
rimmanste
Hello,
I am fairly new to all this macro stuff. I have a macro that keeps
giving me an error only after I place protections on the sheets and
workbook. The macro is triggered by a command button (commandButton1).
The third page in my script is hidden, the other two are not. Ranges
are defined on the first two and they print just fine. Third one has a
formula which used to work but doesn't now. I have tried to figure out
why it has gone awry, and failed. Any help would be appreciated. Here
is the code:
Private Sub CommandButton1_Click()
' Hide_Print_Unhide Macro
' Macro recorded 5/5/2006 by Robert Lizak
'
Dim cell As Range
Dim myPwd As String
myPwd = "secret"
Application.ScreenUpdating = False
Sheets("Stats").PageSetup.PrintArea = "$A$1:$R$46"
Sheets("Stats").PrintPreview
Sheets("Equipment & Background").PageSetup.PrintArea = "$A$1:$F$46"
Sheets("Equipment & Background").PrintPreview
Sheets("Print Sheet").Active
ActiveSheet.Unprotect Password:=myPwd
Sheets("Print Sheet").Visible = True
With Sheets("Print Sheet")
For Each cell In .Range("A1:A712")
If cell.Value = "" Then cell.EntireRow.Hidden = True
Next cell
.PrintPreview
.Range("A1:A712").EntireRow.Hidden = False
.Visible = False
ActiveSheet.Protect Password:=myPwd
End With
Application.ScreenUpdating = True
'
End Sub
runtime error '438'
Object doesn't support this property or method.
-Robert Lizak-
I am fairly new to all this macro stuff. I have a macro that keeps
giving me an error only after I place protections on the sheets and
workbook. The macro is triggered by a command button (commandButton1).
The third page in my script is hidden, the other two are not. Ranges
are defined on the first two and they print just fine. Third one has a
formula which used to work but doesn't now. I have tried to figure out
why it has gone awry, and failed. Any help would be appreciated. Here
is the code:
Private Sub CommandButton1_Click()
' Hide_Print_Unhide Macro
' Macro recorded 5/5/2006 by Robert Lizak
'
Dim cell As Range
Dim myPwd As String
myPwd = "secret"
Application.ScreenUpdating = False
Sheets("Stats").PageSetup.PrintArea = "$A$1:$R$46"
Sheets("Stats").PrintPreview
Sheets("Equipment & Background").PageSetup.PrintArea = "$A$1:$F$46"
Sheets("Equipment & Background").PrintPreview
Sheets("Print Sheet").Active
ActiveSheet.Unprotect Password:=myPwd
Sheets("Print Sheet").Visible = True
With Sheets("Print Sheet")
For Each cell In .Range("A1:A712")
If cell.Value = "" Then cell.EntireRow.Hidden = True
Next cell
.PrintPreview
.Range("A1:A712").EntireRow.Hidden = False
.Visible = False
ActiveSheet.Protect Password:=myPwd
End With
Application.ScreenUpdating = True
'
End Sub
runtime error '438'
Object doesn't support this property or method.
-Robert Lizak-