Solved

---------- LOTS OF PRINTING QUESTIONS -----------

Posted on 1998-12-27
5
148 Views
Last Modified: 2010-05-03
Several printing questions here, so hope that someone can help me out. I guess maybe some of them are pretty simple, but not having used VB to print before then for me they are all equally mystifying.

a) How can I print a bitmap file to a printer from a given  pathname, or do I need to have it in a picture box ? Either way I'm not sure how to do it.

b) I've got a small print routine that sets the printer font to Tahoma and fontsize to 18 and fontbold to true. The first time I use it then all is well, but try it again and it goes back to the printer defaults, even though it goes through the same code again. Am I missing something ?

c) Is it possible to print a control ? By this I mean that if I want a checkbox in the printout, or a command button for example then can I get it to do this - I basically want checkboxes in certain positions in the report. Do I need to have an image of a checkbox and print this instead ? If so then same as question (a)

Well, think thats all for now - hope someone can help out.
I know there are plenty of shareware controls to do printy type things from VB  but really need to know how to do it myself.
Thanks in advance.
Dave
0
Comment
Question by:dgb001
  • 3
5 Comments
 
LVL 1

Expert Comment

by:Renato102098
ID: 1452607
I can find a good performance with Vsview 3.0 (VideoSoft) You can find a free demo.
This is the more flexible tools for print

0
 
LVL 1

Author Comment

by:dgb001
ID: 1452608
Thanks for your proposed answer Renato, and I'm sure the tool you mention is probably useful, but as I said in the question I really do need to know how to do this myself. (i.e the actual code)

Thanks anyway
Dave


0
 
LVL 12

Accepted Solution

by:
mark2150 earned 70 total points
ID: 1452609
a) You have to load the bitmap into some control and then Printer.PrintPicture Control.Image to print the image. You can't print direct from the disk file. But the control doesn't have to be visible so it's not that great a handicap. Also be sure to set AutoSize to true so it'll grow/shrink if all of your disk .BMP's are not exactly the same size.

b) Is known bug in VB where sometimes you have to hit the .FontStyle twice for it to stick. It's also sequence sensitive where you need to set font style, then size, then attributes.

c) Yes you can print a control. No, you won't like the results. The reason is that when you print the control it is rendered like a screen snapshot - at the rez of the screen. Your printer generally will have a much higher rez than the screen and this means that you get a little teeny, hi-rez version or a 1:1 lo-rez version - neither looks particulary good.

One thing you *CAN* to that is neat with VB is that you can have the *SAME* print routine render to both a screen based object and the printer. Simply pass the target into the routine as an OBJECT parameter. If the object is, say, an image control, then your stuff shows up there. If the object is the printer, then your stuff prints there. The neat part is that both are rendered with MAXIMUM POSSIBLE QUALITY. This will give you crisp, sharp text on the printer along with nice, high quality graphics.

Set up your print routine like this:

PRIVATE SUB Render( Tgt AS OBJECT )
Tgt.Print ...
END SUB

Then if you have:

SET TARGET = (some control)
CALL Render( TARGET )

That will show up on your control

if you instead code:

SET TARGET = PRINTER
CALL Render( TARGET )

Now it'll print.

You have to put a little conditional logic in your Render() routine to isolate printer/control specific items. For instance a .CLS doesn't apply to printers and you can't .EndDoc a control. Is not that hard tho.

eMail me and I'll send you operational code if you need more help.

Mark_Lambert@ntsc.navy.mil

M

0
 
LVL 1

Author Comment

by:dgb001
ID: 1452610
Thanks Mark, that all looks pretty good stuff. I will almost certainly e-mail you in the next couple of days (unfortunately my company e-mail isn't working at the moment so I need to keep logging in to Experts Exchange to see if there are any comments or answers - hence I can't e-mail you at the moment either).

Thanks again,
Dave
daveb@banet.net (this is my home e-mail address)

0
 
LVL 1

Author Comment

by:dgb001
ID: 1452611
Just for anyone elses benefit in the future then the following link may prove of use :
http://support.microsoft.com/support/kb/articles/q168/7/44.asp
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…

708 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

20 Experts available now in Live!

Get 1:1 Help Now