Hello,
I am getting the following erro
The error text is
"The instruction at "0x30175034" refernced memory at "0x00000054". Th
memory could not be "read".
OK to terminate
<OK>
This error occurs when I left click the mouse on the print preview of
sheet (TOP 10).
This specific sheet is accessed through a macro on a different shee
(Total Factory).
The point of the macro is to Unhide the TOP 10 sheet, hide unncecessar
columns on this sheet, then do a print preview. Everything works fin
unless the user uses tghe mouse to zoom (left click).
Sub mcrPrintSummary()
Dim month As Integer
Dim LastCol As Integer
Dim PrintPreview As Integer
Application.ScreenUpdating = False
Sheets("Top 10").Visible = True
On Error GoTo CheckError
month = InputBox( _
Prompt:="Please enter month number (1-12).")
If month < 1 Or month > 12 Then
GoTo CheckError
End If
'Hide all columns in report
Application.Goto reference:="HidePage"
ActiveSheet.Unprotect
Selection.EntireColumn.Hidden = True
'Retrieve print or preview value
Application.Goto reference:="PPTF"
PrintPreview = ActiveCell.Value
'Place the month value in the month cell in sheet fncall
Application.Goto reference:="Month"
ActiveCell.Value = month
'Place the number of months into
'Define the column before the beginning of the data
Application.Goto reference:="Data2"
LastCol = ActiveCell.Column
'Unhide first block (KPI Text), middle block (month info), and fina
block (Yearly info)
Application.Goto reference:="Show1"
Selection.EntireColumn.Hidden = False
Application.Goto reference:="Show2"
Selection.EntireColumn.Hidden = False
Application.Goto reference:="Show3"
Selection.EntireColumn.Hidden = False
'unhides the current month to be displayed.
If month < 13 Then
x = month + LastCol
Columns(x).Select
Selection.EntireColumn.Hidden = False
End If
'unhides all quarter values for complete quarters (3,6,9,12)
If month <= 3 Then
ElseIf month <= 6 Then
Range("R1").Select
Selection.EntireColumn.Hidden = False
ElseIf month <= 9 Then
Range("R1:S1").Select
Selection.EntireColumn.Hidden = False
ElseIf month <= 12 Then
Range("R1:T1").Select
Selection.EntireColumn.Hidden = False
End If
'control for option buttons. FnCall holds this value
If PrintPreview = 1 Then
ActiveWindow.SelectedSheets.PrintOut
Else
ActiveWindow.SelectedSheets.PrintPreview
End If
'unhides all for return to normal view
Application.Goto reference:="HidePage"
Selection.EntireColumn.Hidden = False
Application.ScreenUpdating = True
Application.Goto reference:="safety1"
ActiveSheet.Protect
Sheets("Top 10").Visible = False
Exit Sub
CheckError:
Msg = "This is not an integer between 1 and 12!"
If MsgBox(Msg, vbOKOnly) = vbOK Then
End If
ActiveSheet.Protect DrawingObjects:=True, Scenarios:=True
Application.ScreenUpdating = True
End Sub
Has anybody received this error before? What causes it? How can i fi
it?
Thanks
Dav