dbTalk Databases Forums  

Setting Application.Printer.PaperSize

comp.databases.ms-access comp.databases.ms-access


Discuss Setting Application.Printer.PaperSize in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bob Darlington
 
Posts: n/a

Default Setting Application.Printer.PaperSize - 10-08-2010 , 07:42 PM






I'm trying to set a report (cheques) to print on a printer which is not the
default printer using the following code.
My intention is to include in an mde for distribution.
I can get the print run to work OK by manually selecting the Cheque printer
and paper size, but it seems to ignore the following code (even in my local
mdb).

Set Application.Printer = Application.Printers("Cheque Printer")
Application.Printer.PaperSize = acPRPSUser
Application.Printer.ItemSizeHeight = 9.35 ' also tried using twips
but made no difference - 5301.45
Application.Printer.ItemSizeWidth = 26.9 '15252.3
Application.Printer.PaperBin = acPRBNTractor
Application.Printer.BottomMargin = 0
Application.Printer.TopMargin = 0
Application.Printer.LeftMargin = 0
Application.Printer.RightMargin = 0
Application.Printer.Orientation = acPRORPortrait

I've tried running the code before opening the report and in the report
on_open event.
Running Access 2002 on Windows XP.
I can find no help for using the acPRPSUser constant, but feel that that
might be the problem.
Any ideas?

--
Bob Darlington
Brisbane

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Setting Application.Printer.PaperSize - 10-08-2010 , 08:50 PM






Bob Darlington wrote:

Quote:
I'm trying to set a report (cheques) to print on a printer which is not the
default printer using the following code.
My intention is to include in an mde for distribution.
I can get the print run to work OK by manually selecting the Cheque printer
and paper size, but it seems to ignore the following code (even in my local
mdb).

Set Application.Printer = Application.Printers("Cheque Printer")
Application.Printer.PaperSize = acPRPSUser
Application.Printer.ItemSizeHeight = 9.35 ' also tried using twips
but made no difference - 5301.45
Application.Printer.ItemSizeWidth = 26.9 '15252.3
Application.Printer.PaperBin = acPRBNTractor
Application.Printer.BottomMargin = 0
Application.Printer.TopMargin = 0
Application.Printer.LeftMargin = 0
Application.Printer.RightMargin = 0
Application.Printer.Orientation = acPRORPortrait

I've tried running the code before opening the report and in the report
on_open event.
Running Access 2002 on Windows XP.
I can find no help for using the acPRPSUser constant, but feel that that
might be the problem.
Any ideas?

http://bytes.com/topic/access/answer...inter-settings
http://support.microsoft.com/default...b;en-us;210283
http://bytes.com/topic/access/answer...ed-paper-sizes

Then again maybe the printer only accepts specific sized paper.

Reply With Quote
  #3  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Setting Application.Printer.PaperSize - 10-09-2010 , 09:16 PM



"Salad" <salad (AT) oilandvinegar (DOT) com> wrote

Quote:
Bob Darlington wrote:

I'm trying to set a report (cheques) to print on a printer which is not
the default printer using the following code.
My intention is to include in an mde for distribution.
I can get the print run to work OK by manually selecting the Cheque
printer and paper size, but it seems to ignore the following code (even
in my local mdb).

Set Application.Printer = Application.Printers("Cheque Printer")
Application.Printer.PaperSize = acPRPSUser
Application.Printer.ItemSizeHeight = 9.35 ' also tried using
twips but made no difference - 5301.45
Application.Printer.ItemSizeWidth = 26.9 '15252.3
Application.Printer.PaperBin = acPRBNTractor
Application.Printer.BottomMargin = 0
Application.Printer.TopMargin = 0
Application.Printer.LeftMargin = 0
Application.Printer.RightMargin = 0
Application.Printer.Orientation = acPRORPortrait

I've tried running the code before opening the report and in the report
on_open event.
Running Access 2002 on Windows XP.
I can find no help for using the acPRPSUser constant, but feel that that
might be the problem.
Any ideas?


http://bytes.com/topic/access/answer...inter-settings
http://support.microsoft.com/default...b;en-us;210283
http://bytes.com/topic/access/answer...ed-paper-sizes

Then again maybe the printer only accepts specific sized paper.

Salad,
Thanks for the reply, but none of the references you included cover user
defined paper sizes.
As mentioned in my original post, I can set the paper size manually, but not
through the code I posted.
--
Bob Darlington
Brisbane

Reply With Quote
  #4  
Old   
Salad
 
Posts: n/a

Default Re: Setting Application.Printer.PaperSize - 10-09-2010 , 11:23 PM



Bob Darlington wrote:

Quote:
"Salad" <salad (AT) oilandvinegar (DOT) com> wrote in message
news:Q8adnePRUK31VzLRnZ2dnUVZ_h-dnZ2d (AT) earthlink (DOT) com...

Bob Darlington wrote:


I'm trying to set a report (cheques) to print on a printer which is not
the default printer using the following code.
My intention is to include in an mde for distribution.
I can get the print run to work OK by manually selecting the Cheque
printer and paper size, but it seems to ignore the following code (even
in my local mdb).

Set Application.Printer = Application.Printers("Cheque Printer")
Application.Printer.PaperSize = acPRPSUser
Application.Printer.ItemSizeHeight = 9.35 ' also tried using
twips but made no difference - 5301.45
Application.Printer.ItemSizeWidth = 26.9 '15252.3
Application.Printer.PaperBin = acPRBNTractor
Application.Printer.BottomMargin = 0
Application.Printer.TopMargin = 0
Application.Printer.LeftMargin = 0
Application.Printer.RightMargin = 0
Application.Printer.Orientation = acPRORPortrait

I've tried running the code before opening the report and in the report
on_open event.
Running Access 2002 on Windows XP.
I can find no help for using the acPRPSUser constant, but feel that that
might be the problem.
Any ideas?


http://bytes.com/topic/access/answer...inter-settings
http://support.microsoft.com/default...b;en-us;210283
http://bytes.com/topic/access/answer...ed-paper-sizes

Then again maybe the printer only accepts specific sized paper.



Salad,
Thanks for the reply, but none of the references you included cover user
defined paper sizes.
As mentioned in my original post, I can set the paper size manually, but not
through the code I posted.
Here's a link
http://dbaspot.com/forums/ms-access/...el-size-2.html

The code is similar to yours. I didn't see any decimal parts for a
twips value tho you use one in your code. Maybe that is the problem.

Reply With Quote
  #5  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Setting Application.Printer.PaperSize - 10-10-2010 , 06:19 PM



"Salad" <salad (AT) oilandvinegar (DOT) com> wrote

Quote:
Bob Darlington wrote:

"Salad" <salad (AT) oilandvinegar (DOT) com> wrote in message
news:Q8adnePRUK31VzLRnZ2dnUVZ_h-dnZ2d (AT) earthlink (DOT) com...

Bob Darlington wrote:


I'm trying to set a report (cheques) to print on a printer which is not
the default printer using the following code.
My intention is to include in an mde for distribution.
I can get the print run to work OK by manually selecting the Cheque
printer and paper size, but it seems to ignore the following code (even
in my local mdb).

Set Application.Printer = Application.Printers("Cheque Printer")
Application.Printer.PaperSize = acPRPSUser
Application.Printer.ItemSizeHeight = 9.35 ' also tried using
twips but made no difference - 5301.45
Application.Printer.ItemSizeWidth = 26.9 '15252.3
Application.Printer.PaperBin = acPRBNTractor
Application.Printer.BottomMargin = 0
Application.Printer.TopMargin = 0
Application.Printer.LeftMargin = 0
Application.Printer.RightMargin = 0
Application.Printer.Orientation = acPRORPortrait

I've tried running the code before opening the report and in the report
on_open event.
Running Access 2002 on Windows XP.
I can find no help for using the acPRPSUser constant, but feel that that
might be the problem.
Any ideas?


http://bytes.com/topic/access/answer...inter-settings
http://support.microsoft.com/default...b;en-us;210283
http://bytes.com/topic/access/answer...ed-paper-sizes

Then again maybe the printer only accepts specific sized paper.



Salad,
Thanks for the reply, but none of the references you included cover user
defined paper sizes.
As mentioned in my original post, I can set the paper size manually, but
not through the code I posted.

Here's a link
http://dbaspot.com/forums/ms-access/...el-size-2.html

The code is similar to yours. I didn't see any decimal parts for a twips
value tho you use one in your code. Maybe that is the problem.


Thanks Salad.
That was the code I used to build my attempt.
I tried removing the decimal points as you suggested without any luck.

Reply With Quote
  #6  
Old   
Salad
 
Posts: n/a

Default Re: Setting Application.Printer.PaperSize - 10-10-2010 , 06:35 PM



Bob Darlington wrote:
Quote:
"Salad" <salad (AT) oilandvinegar (DOT) com> wrote in message
news:f_qdnVGY2JNfoizRnZ2dnUVZ_u2dnZ2d (AT) earthlink (DOT) com...

Bob Darlington wrote:


"Salad" <salad (AT) oilandvinegar (DOT) com> wrote in message
news:Q8adnePRUK31VzLRnZ2dnUVZ_h-dnZ2d (AT) earthlink (DOT) com...


Bob Darlington wrote:



I'm trying to set a report (cheques) to print on a printer which is not
the default printer using the following code.
My intention is to include in an mde for distribution.
I can get the print run to work OK by manually selecting the Cheque
printer and paper size, but it seems to ignore the following code (even
in my local mdb).

Set Application.Printer = Application.Printers("Cheque Printer")
Application.Printer.PaperSize = acPRPSUser
Application.Printer.ItemSizeHeight = 9.35 ' also tried using
twips but made no difference - 5301.45
Application.Printer.ItemSizeWidth = 26.9 '15252.3
Application.Printer.PaperBin = acPRBNTractor
Application.Printer.BottomMargin = 0
Application.Printer.TopMargin = 0
Application.Printer.LeftMargin = 0
Application.Printer.RightMargin = 0
Application.Printer.Orientation = acPRORPortrait

I've tried running the code before opening the report and in the report
on_open event.
Running Access 2002 on Windows XP.
I can find no help for using the acPRPSUser constant, but feel that that
might be the problem.
Any ideas?


http://bytes.com/topic/access/answer...inter-settings
http://support.microsoft.com/default...b;en-us;210283
http://bytes.com/topic/access/answer...ed-paper-sizes

Then again maybe the printer only accepts specific sized paper.



Salad,
Thanks for the reply, but none of the references you included cover user
defined paper sizes.
As mentioned in my original post, I can set the paper size manually, but
not through the code I posted.

Here's a link
http://dbaspot.com/forums/ms-access/...el-size-2.html

The code is similar to yours. I didn't see any decimal parts for a twips
value tho you use one in your code. Maybe that is the problem.




Thanks Salad.
That was the code I used to build my attempt.
I tried removing the decimal points as you suggested without any luck.

I doubt tractor feed programs have top or bottom margins but maybe right
and left margins need a value > 0.

Set it manually (it prints correctly, right?). What happens if you did
something like
Set Application.Printer = Application.Printers("Cheque Printer")
msgbox Application.Printer.ItemSizeWidth & _
Application.Printer.PaperBin & vbnewline & _
Application.Printer.BottomMargin & vbnewline & _
Application.Printer.TopMargin & vbnewline &_
Application.Printer.LeftMargin & vbnewline &_
Application.Printer.RightMargin & vbnewline &_
Application.Printer.Orientation & vbnewline &_
Application.Printer.PaperSize
and get the current settings?

Step thru the code as well if needed.

Reply With Quote
  #7  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Setting Application.Printer.PaperSize - 10-10-2010 , 09:22 PM



--
Bob Darlington
Brisbane
"Salad" <salad (AT) oilandvinegar (DOT) com> wrote

Quote:
Bob Darlington wrote:
"Salad" <salad (AT) oilandvinegar (DOT) com> wrote in message
news:f_qdnVGY2JNfoizRnZ2dnUVZ_u2dnZ2d (AT) earthlink (DOT) com...

Bob Darlington wrote:


"Salad" <salad (AT) oilandvinegar (DOT) com> wrote in message
news:Q8adnePRUK31VzLRnZ2dnUVZ_h-dnZ2d (AT) earthlink (DOT) com...


Bob Darlington wrote:



I'm trying to set a report (cheques) to print on a printer which is
not the default printer using the following code.
My intention is to include in an mde for distribution.
I can get the print run to work OK by manually selecting the Cheque
printer and paper size, but it seems to ignore the following code
(even in my local mdb).

Set Application.Printer = Application.Printers("Cheque Printer")
Application.Printer.PaperSize = acPRPSUser
Application.Printer.ItemSizeHeight = 9.35 ' also tried using
twips but made no difference - 5301.45
Application.Printer.ItemSizeWidth = 26.9 '15252.3
Application.Printer.PaperBin = acPRBNTractor
Application.Printer.BottomMargin = 0
Application.Printer.TopMargin = 0
Application.Printer.LeftMargin = 0
Application.Printer.RightMargin = 0
Application.Printer.Orientation = acPRORPortrait

I've tried running the code before opening the report and in the
report on_open event.
Running Access 2002 on Windows XP.
I can find no help for using the acPRPSUser constant, but feel that
that might be the problem.
Any ideas?


http://bytes.com/topic/access/answer...inter-settings
http://support.microsoft.com/default...b;en-us;210283
http://bytes.com/topic/access/answer...ed-paper-sizes

Then again maybe the printer only accepts specific sized paper.



Salad,
Thanks for the reply, but none of the references you included cover user
defined paper sizes.
As mentioned in my original post, I can set the paper size manually, but
not through the code I posted.

Here's a link
http://dbaspot.com/forums/ms-access/...el-size-2.html

The code is similar to yours. I didn't see any decimal parts for a twips
value tho you use one in your code. Maybe that is the problem.




Thanks Salad.
That was the code I used to build my attempt.
I tried removing the decimal points as you suggested without any luck.


I doubt tractor feed programs have top or bottom margins but maybe right
and left margins need a value > 0.

Set it manually (it prints correctly, right?). What happens if you did
something like
Set Application.Printer = Application.Printers("Cheque Printer")
msgbox Application.Printer.ItemSizeWidth & _
Application.Printer.PaperBin & vbnewline & _
Application.Printer.BottomMargin & vbnewline & _
Application.Printer.TopMargin & vbnewline &_
Application.Printer.LeftMargin & vbnewline &_
Application.Printer.RightMargin & vbnewline &_
Application.Printer.Orientation & vbnewline &_
Application.Printer.PaperSize
and get the current settings?

Step thru the code as well if needed.

Salad,
I appreciate your perseverance.
I changed the code to:
Application.Printer = Application.Printers("Cheque Printer")
Application.Printer.PaperSize = acPRPSUser
Application.Printer.ItemSizeHeight = 5301
Application.Printer.ItemSizeWidth = 15252
Application.Printer.PaperBin = acPRBNTractor
Application.Printer.BottomMargin = 1
Application.Printer.TopMargin = 1
Application.Printer.LeftMargin = 1
Application.Printer.RightMargin = 1
Application.Printer.Orientation = acPRORPortrait

MsgBox Application.Printer.ItemSizeWidth & vbNewLine & _
Application.Printer.ItemSizeHeight & vbNewLine & _
Application.Printer.PaperBin & vbNewLine & _
Application.Printer.BottomMargin & vbNewLine & _
Application.Printer.TopMargin & vbNewLine & _
Application.Printer.LeftMargin & vbNewLine & _
Application.Printer.RightMargin & vbNewLine & _
Application.Printer.Orientation & vbNewLine & _
Application.Printer.PaperSize

With the following result:
15252
5301
8
1
1
1
1
1
256

So it is accepting the new values, but not using them when I subsequently
open the report (in Preview or normal).
Whilst I want to be able to use this in a distributed mde, this testing is
still being done in the mdb, so the mde is not the problem (yet).
For testing purposes, the 'Cheque' report I am trying to print, is set in
design mode to use the specific printer 'Cheque Printer' and paper size
'A4'.
If I set the paper size to the custom for the report, it works OK in the
mdb, but when I load the mde to the client PC, it resets to A4 -hence the
need for this code.
My current work around is to load the mdb to the client, open it in TS and
reset the paper size, then make the mde on the client PC. I was hoping to
overcome this cumbersome approach.

Reply With Quote
  #8  
Old   
Salad
 
Posts: n/a

Default Re: Setting Application.Printer.PaperSize - 10-10-2010 , 10:42 PM



Bob Darlington wrote:

I changed the code to:
Application.Printer = Application.Printers("Cheque Printer")
Application.Printer.PaperSize = acPRPSUser
Application.Printer.ItemSizeHeight = 5301
Application.Printer.ItemSizeWidth = 15252
Application.Printer.PaperBin = acPRBNTractor
Application.Printer.BottomMargin = 1
Application.Printer.TopMargin = 1
Application.Printer.LeftMargin = 1
Application.Printer.RightMargin = 1
Application.Printer.Orientation = acPRORPortrait

MsgBox Application.Printer.ItemSizeWidth & vbNewLine & _
Application.Printer.ItemSizeHeight & vbNewLine & _
Application.Printer.PaperBin & vbNewLine & _
Application.Printer.BottomMargin & vbNewLine & _
Application.Printer.TopMargin & vbNewLine & _
Application.Printer.LeftMargin & vbNewLine & _
Application.Printer.RightMargin & vbNewLine & _
Application.Printer.Orientation & vbNewLine & _
Application.Printer.PaperSize

With the following result:
15252
5301
8
1
1
1
1
1
256

So it is accepting the new values, but not using them when I
subsequently open the report (in Preview or normal).
Whilst I want to be able to use this in a distributed mde, this testing
is still being done in the mdb, so the mde is not the problem (yet).
For testing purposes, the 'Cheque' report I am trying to print, is set
in design mode to use the specific printer 'Cheque Printer' and paper
size 'A4'.
If I set the paper size to the custom for the report, it works OK in the
mdb, but when I load the mde to the client PC, it resets to A4 -hence
the need for this code. My current work around is to load the mdb to the
client, open it in TS and reset the paper size, then make the mde on the
client PC. I was hoping to overcome this cumbersome approach.


Hi Bob:

Hmmm...I was thinking that you said it worked if you set it manually.
So I think you would like to know the values when it works. Not the
above setting the values and then doing a display. I'm not sure where
you got the initial values to set them to.

Here's a link to MS's site. It's less than you have. Slightly
different. Not as many value changes.
http://support.microsoft.com/kb/284286

Reply With Quote
  #9  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Setting Application.Printer.PaperSize - 10-11-2010 , 01:36 AM



"Salad" <salad (AT) oilandvinegar (DOT) com> wrote

Quote:
Bob Darlington wrote:

I changed the code to:
Application.Printer = Application.Printers("Cheque Printer")
Application.Printer.PaperSize = acPRPSUser
Application.Printer.ItemSizeHeight = 5301
Application.Printer.ItemSizeWidth = 15252
Application.Printer.PaperBin = acPRBNTractor
Application.Printer.BottomMargin = 1
Application.Printer.TopMargin = 1
Application.Printer.LeftMargin = 1
Application.Printer.RightMargin = 1
Application.Printer.Orientation = acPRORPortrait

MsgBox Application.Printer.ItemSizeWidth & vbNewLine & _
Application.Printer.ItemSizeHeight & vbNewLine & _
Application.Printer.PaperBin & vbNewLine & _
Application.Printer.BottomMargin & vbNewLine & _
Application.Printer.TopMargin & vbNewLine & _
Application.Printer.LeftMargin & vbNewLine & _
Application.Printer.RightMargin & vbNewLine & _
Application.Printer.Orientation & vbNewLine & _
Application.Printer.PaperSize

With the following result:
15252
5301
8
1
1
1
1
1
256

So it is accepting the new values, but not using them when I subsequently
open the report (in Preview or normal).
Whilst I want to be able to use this in a distributed mde, this testing is
still being done in the mdb, so the mde is not the problem (yet).
For testing purposes, the 'Cheque' report I am trying to print, is set in
design mode to use the specific printer 'Cheque Printer' and paper size
'A4'.
If I set the paper size to the custom for the report, it works OK in the
mdb, but when I load the mde to the client PC, it resets to A4 -hence the
need for this code. My current work around is to load the mdb to the
client, open it in TS and reset the paper size, then make the mde on the
client PC. I was hoping to overcome this cumbersome approach.


Hi Bob:

Hmmm...I was thinking that you said it worked if you set it manually. So I
think you would like to know the values when it works. Not the above
setting the values and then doing a display. I'm not sure where you got
the initial values to set them to.

Here's a link to MS's site. It's less than you have. Slightly different.
Not as many value changes. http://support.microsoft.com/kb/284286
Thanks again.
From that article, I changed my code to read:

Application.Printer = Application.Printers("Cheque Printer")
DoCmd.OpenReport "rCheque", 2, , "PropNum = " & gblPropNum, acHidden
Set rpt = Reports!rCheque
With rpt.Printer
.DefaultSize = False
.PaperSize = acPRPSUser
.ItemSizeHeight = 5301
.ItemSizeWidth = 15252
.BottomMargin = 0
.TopMargin = 0
.LeftMargin = 0
.RightMargin = 0
.Orientation = acPRORPortrait
.PaperBin = acPRBNTractor
End With

DoCmd.OpenReport "rCheque", 2, , "PropNum = " & gblPropNum

Still opens with paper size set to 'Letter'.
If I set the printer up manually, and check the values, I get the same as
above.
The original values were found by trial and error on the client's printer.
It prints onto preprinted cheque forms, so the measurements need to be
accurate.
So it appears to accept the correct values, but not apply them to the
report.
I've also tried changing the paper size for another report (formatted for
A4) using my default printer and paper bin settings, but it still won't
work.
Whenever I use acPRPSUser, I always get 'Letter' - even if I use A4
dimensions for .ItemSize.. properties.

Reply With Quote
  #10  
Old   
David-W-Fenton
 
Posts: n/a

Default Re: Setting Application.Printer.PaperSize - 10-11-2010 , 11:43 AM



Salad <salad (AT) oilandvinegar (DOT) com> wrote in
news:f_qdnVGY2JNfoizRnZ2dnUVZ_u2dnZ2d (AT) earthlink (DOT) com:

Quote:
I didn't see any decimal parts for a
twips value tho you use one in your code. Maybe that is the
problem.
Twips are always whole numbers, no fractions.

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.