Solved

printing problem with commondialog

Posted on 1999-01-24
4
162 Views
Last Modified: 2010-05-03
I am able to show out the print dialog box with the
commondialog1.showprinter command
but I am not able to execute the printing when Ok button is pressed.Please advice me on what I have lack??
0
Comment
Question by:yyl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Accepted Solution

by:
kianwei earned 100 total points
ID: 1470360
Common Dialog only used for select/change printer properties. i.e. It's
will change the printer property after u press 'OK'.

U need extra statement to print the trigger the printing, for example, if u r using
the Crystal Report, u need to set the Action property to 1 (Crytal.Action = 1)
to start print the report.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1470361
You have to add a series of Printer.Print statements to get anything to actually *go* to the printer. You can also draw lines and circles and such with Printer.Line, Printer.Circle. Basically you treat it as any other control. .CurrentX and .CurrentY allow you control of the cursor, .FontSize and related commands control the fonts, etc. You have to finish up with a Printer.EndDoc in order to submit the job into the print queue.

Windows stands between your app and the printer. You send out a bunch of printer commands and they *do not* go directly to the printer! They go to a "meta" device. Advantage to this is that you can move up the page as well as down, etc. Then when your code sends a .EndDoc this alerts Windows that you're done using the app.

Windows then looks at the printer device specifics and converts your "meta" page into a series of commands specific for the printer you selected with the CommonDialog control. *THEN* data is sent to the printer - not before. The other advantage to this is that your code will render at the "best possible" resolution/quality depending on the specifics of the printer and *NOT* on the basis of your code. This allows your program to automatically upgrade it's print quality when a "better" printer is selected.

M

0
 

Author Comment

by:yyl
ID: 1470362
I am actually trying to print the text in picture1 using vb5.Can you please show example of the code.
Much appreciate also if you could let me know where to look for the helps topic on " commondialog box_print" as  I am unable to find it in MS Visual Basic Helps.
Thanks for your kind attention.

0
 
LVL 12

Expert Comment

by:mark2150
ID: 1470363
Picture1.Print "This is a line of text"

Look in the help on "CommonDialog Control (Print Dialog)"

But this does *NOT* actually print anything. It just allows you to connect to the printer. Your code still needs to send print commands.

If you want to print an image you need to code:

Printer.PaintPicture Picture1.Picture, x, y

This will print the contents of a picture box including any text that was placed in it. However you might find you get better results by printing the image without text and then printing the text on the printer. This will generally give you higher quality text than printing the text in the picture box.

M

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

628 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