Solved

printing problem with commondialog

Posted on 1999-01-24
4
154 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
  • 2
4 Comments
 

Accepted Solution

by:
kianwei earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 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

12 Experts available now in Live!

Get 1:1 Help Now