PDA

View Full Version : PrintPreview failed



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

Bob Phillips
09-25-2008, 06:36 AM
Is the sheet that you lookup a hidden sheet?

sheldon
09-25-2008, 06:39 AM
Yes it is.

Bob Phillips
09-25-2008, 07:05 AM
The unhide it,printpreview, and hide it again.

sheldon
09-25-2008, 07:48 AM
Hi sorry, i got that wrong.

The workbook is a sheet with options on, which then links to other hiden sheets. The code opens the linked sheets, which have been selected in the first sheet.

Bob Phillips
09-25-2008, 07:52 AM
Can you post the workbook the, so we can see what is what?

sheldon
09-26-2008, 03:56 AM
I'm not able to upload the workbook.

Sorry I know this makes it a lot harder without being able to see the workbook. But the document contains confidential information.

Do you need anymore information about the code or configuration of the document?

Thanks

Bob Phillips
09-26-2008, 04:15 AM
Can't you obfuscate the data?