Print preview for excel 2007 not working

ManvinderKaur

Board Regular
Joined
Jun 16, 2010
Messages
149
Hi I am using following code on a command button for print preview and print command (in Excel 2003). That is working perfectly in excel 2003. But this is not working in excel 2007.
Code:
'command button to print site survey 
Private Sub cmdPrintSiteSurvey_Click()
On Error GoTo ErrorLine
Application.ScreenUpdating = False
Dim SiteSurveyEnegy As VbMsgBoxResult
' message box to prompt print out
SiteSurveyEnegy = MsgBox("Do you want to take print out of Site Survey Energy Sheet", vbYesNo + vbQuestion, "Print Out")

If SiteSurveyEnegy = vbYes Then

    With Worksheets("3.0 Site Survey Energy Print")
        .Visible = True
        .PageSetup.PrintArea = "$A$1:$J$38"
        .PrintPreview
        .Visible = False
    End With
    
End If
Application.ScreenUpdating = True
Exit Sub
ErrorLine:
MsgBox ("Error Number:" & Err.Number & ". " & Err.Description & ". Source:" & Err.Source)
ActiveWorkbook.Close
End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
in excel 2003 that is working perfectly. But in excel 2007 The print preview is there but there is no option for print. I can not use anything other than closing excel. Everything seems read only.
 
Upvote 0
Code works 'as is' for me in Excel 2007.
 
Upvote 0
no same normal ribbon as on other sheets. But not this ribben and all ribben becomes read only . but preview is there but ribben is not there...
 
Upvote 0
I have used following code now perfect
Code:
'command button to print site survey 
Private Sub cmdPrintSiteSurvey_Click()
On Error GoTo ErrorLine
[COLOR=red]'Application.ScreenUpdating = False[/COLOR]
Dim SiteSurveyEnegy As VbMsgBoxResult
' message box to prompt print out
SiteSurveyEnegy = MsgBox("Do you want to take print out of Site Survey Energy Sheet", vbYesNo + vbQuestion, "Print Out")

If SiteSurveyEnegy = vbYes Then

    With Worksheets("3.0 Site Survey Energy Print")
        .Visible = True
        .PageSetup.PrintArea = "$A$1:$J$38"
        .PrintPreview
        .Visible = False
    End With
    
End If
[COLOR=red]'Application.ScreenUpdating = True[/COLOR]
Exit Sub
ErrorLine:
MsgBox ("Error Number:" & Err.Number & ". " & Err.Description & ". Source:" & Err.Source)
ActiveWorkbook.Close
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,915
Members
448,532
Latest member
9Kimo3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top