Hello
A few days ago I face the frustrating situation of trying to print from a
VB 6 application running under Windows XP to a dot-matrix printer using a preprinted, continuos form with a custom size of 8.5 x 5.5 inches.
I spent a lot of time searching on the internet for a code, a component or a tip to solve the problem as I personally don't enjoy spending hours programming.
THe thing is that I read a lot of information about using printer.height, printer.width, printer.papersize, installing new drivers, etc until I deleted the printer.heigh and printer.width commands from my code and everything runned as expected, i didn't use the printer.papersize either, but the printer stopped exactly at the 5.5 inches and no paper was ejected no mattering I ended my code using printer.enddoc command.
What I did :
1. I created a custom paper size at Start/printers&faxes and in the main menu File/server properties, I clicked on "create new form", gave a name and typed the width and height of my custom page size, then clicked "save form" and close the window.
2. On the printers & faxes window, Right click over your printer and select printing preferences and in the dialog you will see a button called "Advance options" click on it, this will show the advance properties of your printer.
You will see a field called "Paper Size" and a combo box in which you will have to select your customized page size. Once selected click "Ok" and close everything.
I tested changing the paper size inside my printer properties, but was enough selecting my new paper size in the Advance options.
3. In my code, I was using the printer.height=7920 and printer.width=12240, I never used the printer.papersize as I read that when assigning printer.height and printer.width, printer.papersize was set to user defined by default, so no need to include it.
I just commented the printer.height=7920 and the printer.width=12240 commands to give it a try and included a msgbox printer.height just before the printer.enddoc to see if before printing the height was 7920 (5.5 inches x 1440 = 7920) as I needed and so it was, the height was taken from my custom paper size and the printer.enddoc command printed everything correctly and ejected just the paper needed to set the next form right in place.
I noticed that when leaving the printer.height and printer.width commands, this values were not used, the advanced properties pagesize i selected was not applied, and a "letter" paper size height was used as default, but when I commented these commands, the height used was the one i determined in my custom paper size.
A very simple code i used:
Code:
'=================================================
Function PrintCompact()
Printer.PrintQuality = vbPRPQDraft
'printer.height=7920
'printer.width=12240
Printer.FontSize = 8
Printer.CurrentX = 7537
Printer.CurrentY = 5268
Printer.Print "Hello"
Printer.CurrentX = 5670
Printer.CurrentY = 1417
Printer.Print "Hello again"
Printer.FontSize = 10
Printer.CurrentX = 0
Printer.CurrentY = 500
Printer.Print "Hola"
Printer.FontSize = 8
Printer.CurrentX = 7537
Printer.CurrentY = 500
Printer.Print "Bye"
'msgbox printer.height
Printer.EndDoc
End Function
'=================================================
I hope you find useful this experience I had and saves you some time and frustration.
All the best
