Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 20th, 2009, 02:54 AM
Registered User
 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Thumbs up printing in custom paper size in visual basic

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
Reply With Quote
The Following User Says Thank You to Babet For This Useful Post:
ArunKakkar (May 26th, 2010)
  #2 (permalink)  
Old April 30th, 2010, 03:15 AM
Registered User
 
Join Date: Apr 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up printing in custom paper size in visual basic

thanks a lot.I followed your steps and it worked.I had searched a lot in net of this ,even trying lot of codes it always gave the size of 'letter'.
Reply With Quote
  #3 (permalink)  
Old May 26th, 2010, 01:48 AM
Registered User
 
Join Date: May 2010
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Smile Thanks a Lot, I am struggling since many days to short out this problem

Thanks a Lot, I am struggling since many days to short out this problem
I request you to post your this article at many other places if possible or allow me to post it on my blog http://ArunKakkar1.blogspot.com

Once Again Thanks a lot
Reply With Quote
  #4 (permalink)  
Old November 29th, 2013, 02:06 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried what you said. I cannot find the 'paper size' combobox in advanced properties. I tried printing preferences, there is a paper size combobox but, i cannot find the form size i just created. There's only a4,a5 etc. How can I include the newly created size??
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Paper Size (custom also) to default Printer gaurikhot .NET Framework 2.0 2 December 6th, 2008 12:50 AM
printing in custom paper size in visual basic imagetvr Pro VB 6 2 May 3rd, 2008 08:58 PM
Problem with custom paper size adrineh Crystal Reports 0 August 26th, 2006 03:21 AM
Printing problem using dot-matrix paper size ismail_m HTML Code Clinic 1 January 1st, 2006 08:51 AM
Printing problem in Visual Basic ! Urgent venkatesh_anmca Beginning VB 6 2 January 29th, 2005 01:22 AM



All times are GMT -4. The time now is 12:02 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.