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