sheldon
09-25-2008, 06:08 AM
Hi,
I have an excel document with a print preview button. For some unknown reason is bringing up an error message "PrintPreview method of worksheet class failed"
This is the code used...
Sub FormatAndPreview()
Dim sSheetName As String
On Error Resume Next
sSheetName = Application.VLookup(Range("K10").Value, Range("F117:G125"), 2, False)
On Error GoTo 0
If sSheetName <> "" Then
With Sheets(sSheetName)
.Rows.AutoFit
.PrintPreview
End With
Else
MsgBox "You have not selected a Contract Type", vbOKOnly + vbInformation, "Information"
End If
End Sub
Have you any ideas why this could be?
Thanks
I have an excel document with a print preview button. For some unknown reason is bringing up an error message "PrintPreview method of worksheet class failed"
This is the code used...
Sub FormatAndPreview()
Dim sSheetName As String
On Error Resume Next
sSheetName = Application.VLookup(Range("K10").Value, Range("F117:G125"), 2, False)
On Error GoTo 0
If sSheetName <> "" Then
With Sheets(sSheetName)
.Rows.AutoFit
.PrintPreview
End With
Else
MsgBox "You have not selected a Contract Type", vbOKOnly + vbInformation, "Information"
End If
End Sub
Have you any ideas why this could be?
Thanks