print sizes

1

123xxxxx

can some1 tell me wots wrong wiv the coding i got from microsoft office
site. i am trying to get the code for the printing size but it just comes
out with the number on it



' Variable to hold the default printer index.

Dim strDefaultPrinter As String



' Variable to hold the printer object.

Dim prt As Printer



' Variable to hold the report object while cycling

' through the AllReports collection.

Dim accObj As AccessObject



' Fill the printer list.

' Make sure the RowSource is empty.

Me!cmbPrinter.RowSource = ""

Me!lbxSelectReport.RowSource = ""



' Cycle through the printers installed on the machine and add them to the
combo box.

For Each prt In Application.Printers

' Use the new AddItem method to add the printer name to the combo box.

Me!cmbPrinter.AddItem prt.DeviceName

Next



' Remember the default printer.

strDefaultPrinter = Application.Printer.DeviceName



' Set the combo box to the default printer.

Me!cmbPrinter = strDefaultPrinter

Me![cmbPaperSize] = 1



' Fill the report list.

For Each accObj In CurrentProject.AllReports

Me!lbxSelectReport.AddItem accObj.Name

Next



' Set the list box to the first report.

Me!lbxSelectReport.SetFocus

Me!lbxSelectReport.ListIndex = 0





i am assuming the author of this code knew wot he/she was doing, can you
tell me if this is correct

as i know little about vba, i.e. i am just a beginner
 
1

123xxxxx

yeah ok, but i have come accross a similar coding but it seems to work, i
hear u say y not use that, well, its because the full code doesnt have the
functionality that i want
Allen Browne said:
The Printer object does return a value for the preset paper sizes.

The number matches one of these contstants:
1 acPRPSLetter
2 acPRPSLetterSmall
3 acPRPSTabloid
4 acPRPSLedger
5 acPRPSLegal
6 acPRPSStatement
8 acPRPSA3
9 acPRPSA4
10 acPRPSA4Small
11 acPRPSA5
12 acPRPSB4
13 acPRPSB5
14 acPRPSFolio
15 acPRPSQuarto
16 acPRPS10x14
17 acPRPS11x17
18 acPRPSNote
19 acPRPSEnv9
20 acPRPSEnv10
21 acPRPSEnv11
22 acPRPSEnv12
23 acPRPSEnv14
24 acPRPSCSheet
25 acPRPSDSheet
26 acPRPSExecutive
27 acPRPSEnvDL
28 acPRPSEnvC5
29 acPRPSEnvC3
30 acPRPSEnvC4
31 acPRPSEnvC6
32 acPRPSEnvC65
33 acPRPSEnvB4
34 acPRPSEnvB5
35 acPRPSEnvB6
36 acPRPSEnvItaly
37 acPRPSEnvMonarch
38 acPRPSEnvPersonal
39 acPRPSESheet
39 acPRPSFanfoldUS
40 acPRPSFanfoldStdGerman
41 acPRPSFanfoldLglGerman
256 acPRPSUser

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to the newsgroup. (Email address has spurious "_SpamTrap")

123xxxxx said:
can some1 tell me wots wrong wiv the coding i got from microsoft office
site. i am trying to get the code for the printing size but it just comes
out with the number on it

' Variable to hold the default printer index.
Dim strDefaultPrinter As String
' Variable to hold the printer object.
Dim prt As Printer
' Variable to hold the report object while cycling
' through the AllReports collection.
Dim accObj As AccessObject
' Fill the printer list.
' Make sure the RowSource is empty.
Me!cmbPrinter.RowSource = ""
Me!lbxSelectReport.RowSource = ""

' Cycle through the printers installed on the machine and add them to
the combo box.

For Each prt In Application.Printers
' Use the new AddItem method to add the printer name to the combo box.
Me!cmbPrinter.AddItem prt.DeviceName
Next

' Remember the default printer.
strDefaultPrinter = Application.Printer.DeviceName

' Set the combo box to the default printer.
Me!cmbPrinter = strDefaultPrinter
Me![cmbPaperSize] = 1

' Fill the report list.
For Each accObj In CurrentProject.AllReports
Me!lbxSelectReport.AddItem accObj.Name
Next

' Set the list box to the first report.
Me!lbxSelectReport.SetFocus
Me!lbxSelectReport.ListIndex = 0


i am assuming the author of this code knew wot he/she was doing, can you
tell me if this is correct

as i know little about vba, i.e. i am just a beginner
 
1

123xxxxx

soz the one i on about had a source where it got its paper sizes from in a
table thanks for your help in the matter

Allen Browne said:
The Printer object does return a value for the preset paper sizes.

The number matches one of these contstants:
1 acPRPSLetter
2 acPRPSLetterSmall
3 acPRPSTabloid
4 acPRPSLedger
5 acPRPSLegal
6 acPRPSStatement
8 acPRPSA3
9 acPRPSA4
10 acPRPSA4Small
11 acPRPSA5
12 acPRPSB4
13 acPRPSB5
14 acPRPSFolio
15 acPRPSQuarto
16 acPRPS10x14
17 acPRPS11x17
18 acPRPSNote
19 acPRPSEnv9
20 acPRPSEnv10
21 acPRPSEnv11
22 acPRPSEnv12
23 acPRPSEnv14
24 acPRPSCSheet
25 acPRPSDSheet
26 acPRPSExecutive
27 acPRPSEnvDL
28 acPRPSEnvC5
29 acPRPSEnvC3
30 acPRPSEnvC4
31 acPRPSEnvC6
32 acPRPSEnvC65
33 acPRPSEnvB4
34 acPRPSEnvB5
35 acPRPSEnvB6
36 acPRPSEnvItaly
37 acPRPSEnvMonarch
38 acPRPSEnvPersonal
39 acPRPSESheet
39 acPRPSFanfoldUS
40 acPRPSFanfoldStdGerman
41 acPRPSFanfoldLglGerman
256 acPRPSUser

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to the newsgroup. (Email address has spurious "_SpamTrap")

123xxxxx said:
can some1 tell me wots wrong wiv the coding i got from microsoft office
site. i am trying to get the code for the printing size but it just comes
out with the number on it

' Variable to hold the default printer index.
Dim strDefaultPrinter As String
' Variable to hold the printer object.
Dim prt As Printer
' Variable to hold the report object while cycling
' through the AllReports collection.
Dim accObj As AccessObject
' Fill the printer list.
' Make sure the RowSource is empty.
Me!cmbPrinter.RowSource = ""
Me!lbxSelectReport.RowSource = ""

' Cycle through the printers installed on the machine and add them to
the combo box.

For Each prt In Application.Printers
' Use the new AddItem method to add the printer name to the combo box.
Me!cmbPrinter.AddItem prt.DeviceName
Next

' Remember the default printer.
strDefaultPrinter = Application.Printer.DeviceName

' Set the combo box to the default printer.
Me!cmbPrinter = strDefaultPrinter
Me![cmbPaperSize] = 1

' Fill the report list.
For Each accObj In CurrentProject.AllReports
Me!lbxSelectReport.AddItem accObj.Name
Next

' Set the list box to the first report.
Me!lbxSelectReport.SetFocus
Me!lbxSelectReport.ListIndex = 0


i am assuming the author of this code knew wot he/she was doing, can you
tell me if this is correct

as i know little about vba, i.e. i am just a beginner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top