Hello.
I have a macro, ran from a control button on the worksheet, that unprotects the worksheet, then resizes an object located on a chart, prints a range, then re-protects the worksheet.
When I press the button for the macro, only the printing is done (it does not resize the object). But, when I run the code line by line in the VB editor, it runs properly and resizes the object!
This is the code I'm using:
-----------
Sub PrintReport()
' Unprotect Worksheet
ActiveCell.Activate
Application.ScreenUpdating = False
Sheets("Report").Activate
ActiveSheet.Unprotect Password:="earth"
' Make sure chart legend is in correct position
Sheets("Report").Activate
ActiveSheet.ChartObjects("Chart 11").Activate
ActiveChart.ChartArea.Select
ActiveChart.Shapes("Group 23").Select
Selection.Width = 413
Selection.Height = 45
Selection.ShapeRange.Left = 65
Selection.ShapeRange.Top = 10
' Print completed report sheet
Sheets("Report").Activate
Range("A1:I56").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$I$56"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Range("E2:I4").Select
' Re-protect Worksheet
Application.ScreenUpdating = True
ActiveSheet.Protect Password:="earth"
End Sub
-------------
Any ideas as to why it won't run properly? I'm using XL97.
Thanks,
Corey
I have a macro, ran from a control button on the worksheet, that unprotects the worksheet, then resizes an object located on a chart, prints a range, then re-protects the worksheet.
When I press the button for the macro, only the printing is done (it does not resize the object). But, when I run the code line by line in the VB editor, it runs properly and resizes the object!
This is the code I'm using:
-----------
Sub PrintReport()
' Unprotect Worksheet
ActiveCell.Activate
Application.ScreenUpdating = False
Sheets("Report").Activate
ActiveSheet.Unprotect Password:="earth"
' Make sure chart legend is in correct position
Sheets("Report").Activate
ActiveSheet.ChartObjects("Chart 11").Activate
ActiveChart.ChartArea.Select
ActiveChart.Shapes("Group 23").Select
Selection.Width = 413
Selection.Height = 45
Selection.ShapeRange.Left = 65
Selection.ShapeRange.Top = 10
' Print completed report sheet
Sheets("Report").Activate
Range("A1:I56").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$I$56"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Range("E2:I4").Select
' Re-protect Worksheet
Application.ScreenUpdating = True
ActiveSheet.Protect Password:="earth"
End Sub
-------------
Any ideas as to why it won't run properly? I'm using XL97.
Thanks,
Corey