PaperSize Property in Xl97 via XP

G

Greg

NT - XL97
-----------------------------------------------------------
Hi,

I have the following printing userform command button code
that runs fine in 97 but apparently produces a run-time
(paper size property) error in XP.

I don't have XP here so could someone help me adapt it so
would work for both versions?

Here is my code, ob stands for option button.

Code:
***********************************
Private Sub OKButton_Click()
Dim i As Integer

Application.ScreenUpdating = False
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
With Sheets(ListBox1.List(i))

If obPaperLetter Then .PageSetup.PaperSize
= xlPaperLetter
If obPaperLegal Then .PageSetup.PaperSize
= xlPaperLegal
If obPaperA4 Then .PageSetup.PaperSize =
xlPaperA4

.PrintOut
End With

End If
Next i
Application.ScreenUpdating = True

Unload Me
End Sub
***********************************************

Thanks a lot!
Greg
 
J

Jim Cone

Greg,

My guess is the sheet names are not the same in XL97 and XL 2002.
Are you loading predefined names into the list box or picking up the
sheet names from the Active Workbook?

Regards,
Jim Cone
San Francisco, CA
 
K

keepITcool

why set the papersize at all?

In general people will have their printers loaded with 1 papersize.
certainly in europe.. 99,9 percent of office printers have a4, and the
rest is a3 or it might be a labelprinter:)

Why not just go with their default printer?

(just give m message when their current printer is not set to either
legal/letter or a4)









keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
G

Greg

I am picking them up from the ActiveWorkbook
However, for one of them I use CodeName. see code below Is
this the reason?
Let me test it.
Thanks for the input!
Greg

For Each sht In ActiveWorkbook.Worksheets

If sht.CodeName <> "Sht3_Claim_Detail" Then
If sht.Visible = xlSheetVisible Then
ListBox1.AddItem sht.Name
End If
Next sht
-----Original Message-----
Greg,

My guess is the sheet names are not the same in XL97 and XL 2002.
Are you loading predefined names into the list box or picking up the
sheet names from the Active Workbook?

Regards,
Jim Cone
San Francisco, CA

"Greg" <[email protected]> wrote in
message news:[email protected]...
 
G

Greg

For some reason when they try to print it in London it
defaults to letter. Likewise, when they send it here to
US, my printer says please load A4.
 
K

keepITcool

probably the 'allow letter to a4 resizing' option.. :)

or try:
Sub SwapPaper()
ActiveSheet.PageSetup.PaperSize = IIf( _
Application.International(xlMetric), _
xlPaperA4, xlPaperLetter)
End Sub



keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
Top