Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

printing problem with commondialog

Posted on 1999-01-24
4
Medium Priority
?
165 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 200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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.
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…
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…

916 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