View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Excel PageSetup Error even when a printer Exists

Jo,
What Debug.Print lOrientation = xlLandscape show ?

NickHk

"jo" wrote in message
oups.com...
Hi,

we run batch jobs to create Excel document. The code worked fine in XP
but in Win 2k it fails wiht the following error:

Description: Unable to set the Orientation property of the PageSetup
class

I have a default printer installed and the job complets some times but
most of the time it fails. The printer has all the required [its a
XEROX workstation] properties but the job failes.

there are looot of addins that formats their final excel document and
most of them failes.

here is a sample code:

With ActiveWorkbook
For Each wsSheet In .Worksheets ' Go through all worksheets
With wsSheet
With .PageSetup ' Set PageSetup properties
If (lOrientation 0) Then .Orientation =
lOrientation 'its a long and value is 2
If bCenterHorizontally Then
.CenterHorizontally = True
If bCenterVertically Then .CenterVertically
= True
If Len(sTitleRows) 0 Then .PrintTitleRows
= sTitleRows
If Len(sTitleColumns) 0 Then
.PrintTitleColumns = sTitleColumns
If Len(sPrintArea) 0 Then .PrintArea =
sPrintArea
If dTopMargin 0 Then .TopMargin =
dTopMargin
If dBottomMargin 0 Then .BottomMargin =
dBottomMargin
If dLeftMargin 0 Then .LeftMargin =
dLeftMargin
If dRightMargin 0 Then .RightMargin =
dRightMargin
End With
End With
Next wsSheet

End With

do we need to change any settings in the system???

can any one help in this???