Solved

printer object -> Papersize

Posted on 2002-05-22
7
272 Views
Last Modified: 2010-05-18
This is bit tricky. I have two printers. One of the printers is connecting theUSB cable and the other one connecting the serial cable.

One of the printer prints in a regular paper and the other one have to print on a form (8.5 *3.66 inch).

According to the printer technical support, we set the form size in printer properties.

In code:

'This is to set the printer name to print form
Dim idx As Long
Dim p As Printer
Dim X As Long
For Each p In Printers
If (p.DeviceName = "form") Then
Set Printer = Printers(idx)
End If
idx = idx + 1

Next p

Printer.Width = 8.5 * 1440 '11520
Printer.Height = 3.66 * 1440 '5268

Printer.ScaleMode = vbCentimeters '5 'set to inch

Printer.Print "pirnting"
Printer.Print "pirnting"
Printer.Print "pirnting"
Printer.Print "pirnting"
Printer.EndDoc

'This is to set the printer name to print report (this is the one printing on regular paper)
Dim idx As Long
Dim p As Printer
Dim X As Long
For Each p In Printers
If (p.DeviceName = "report") Then
Set Printer = Printers(idx)
End If
idx = idx + 1
Next p
'Printing a report here….
rept.PrintReport

This is the code I am executing. My problem, the form is printing good on the first two times, but after that it’s printing on every third form (3.66 is 1 third of regular paper length).
I message out printer.height and printer.width to check. On the first time I am getting
H: 5270 (3.66)
W: 12240 (8.5)

Second time:
H: 15840 (11)
W: 12240 (8.5)

That means my setting of printer.height = 8.5 * 1440 and printer.width = 3.66 * 1440 is not getting affect.

Can anyone help me please?

Thank you,
Kethees
0
Comment
Question by:kethees
7 Comments
 
LVL 3

Expert Comment

by:ketapillar
ID: 7027379
What type of printers are they? Model Numbers
0
 
LVL 3

Expert Comment

by:ketapillar
ID: 7027383
We have Epson LQ-570+ (dot matrix pos's) and the driver for them does not hold the correct papersize.  Instead we had to use another driver (from another epson printer) to hold the correct paper size.

I ended up having to call tech support pay them $20 (out of warranty) for them to tell me the correct drivers to use.
0
 

Author Comment

by:kethees
ID: 7027402
to print the form, i am using Lexmark 2480 (form printer)
and to print the report, using Epson 880

Adidtional comment:
'this is to set the printer name to print wave bill
   Dim idx As Long
   Dim p As Printer
   Dim X As Long
   For Each p In Printers
      If (p.DeviceName = "report") Then
         Set Printer = Printers(idx)
      End If
      idx = idx + 1
       
   Next p
   
   MsgBox "wedth " & Printer.Width / 1440
   getting: 8.5
   MsgBox "hei " & Printer.Height / 1440
   getting: 3.66
   Printer.Width = 8.5 * 1440 '11520
   Printer.Height = 2 * 1440 '5268
   MsgBox "wedth " & Printer.Width / 1440
   getting: 8.5
   MsgBox "hei " & Printer.Height / 1440
   getting: 11
   Printer.ScaleMode = vbCentimeters '5 'set to inch
   Printer.Print "testing some new print"
   Printer.EndDoc
   MsgBox "wedth " & Printer.Width / 1440
   getting: 8.5
   MsgBox "hei " & Printer.Height / 1440
   getting: 3.66

That seems like, my setting is not getting any affect.:(
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:ventond
ID: 7028371
I don't know as this will help, but I found the printer object to be very finicky about accepting changes. Instead of using the Printer Object can you try breaking out of your loop when you find a match and then using p instead of Printer?

If that doesn't work, I think your command "Set Printer = Printers(ndx)" should be "Set Printer = p". Since a collection (which Printers is) doesn't necessarily have to have sequential indexes.

0
 
LVL 1

Expert Comment

by:tandrei
ID: 7028980
I had this problem too, in fact I was not able at all to modify the paper size on a HP LJ printer. I am using the common dialog Showprinter to select the paper size, but the [printer object seems not to be aware of any changes
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7818392
Hi kethees,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

kethees, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7909871
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Input past end of file vbs script 9 81
VB6 code to programmatically convert pdf to excel 21 69
VBA saving file message display 5 56
MS Access - Capture pressed key onclick 4 28
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now