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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try removing

Code:
Application.ScreenUpdating = False
 

ManvinderKaur

Board Regular
Joined
Jun 16, 2010
Messages
149
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.
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
55,039
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Code works 'as is' for me in Excel 2007.
 

ManvinderKaur

Board Regular
Joined
Jun 16, 2010
Messages
149

ADVERTISEMENT

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...
 

ManvinderKaur

Board Regular
Joined
Jun 16, 2010
Messages
149
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,111
Messages
5,857,448
Members
431,880
Latest member
kar2rost

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
Top