Printing to a printer in VBA 6.5

B

bnadler

There does not seem to be an object (that I can find) to send data to a
printer. In VB6 you use Printer.Print (expression). There is not a Printer
object in VBA. However, there is the Printout method, but that (as far as I
can tell) does not give line by line print control. How do you print line by
line in VBA 6.5?
 
C

Clif McIrvin

bnadler said:
There does not seem to be an object (that I can find) to send data to
a
printer. In VB6 you use Printer.Print (expression). There is not a
Printer
object in VBA. However, there is the Printout method, but that (as
far as I
can tell) does not give line by line print control. How do you print
line by
line in VBA 6.5?


I havn't tried to do what you're asking ... but having made the jump to
VBA directly from GWBASIC (with a several year gap in between <grin>)
how about VBA's Open and Print # statements?

Another possibility to explore is VBA's OpenAsTextStream Method.

HTH!
 
B

bnadler

That would entail opening a file that has a single line of data (I think ).
It seems ridiculous that VBA has so much capability, but doesn't have the
Printer object. It is nothing to print pretty much anything in VB6 yet you
cannot seem to do this in VBA. I'm going to try and use the Printout method
by pre-formatting the info using programming controls in a different page.
 
S

Steve Rindsberg

There does not seem to be an object (that I can find) to send data to a
printer. In VB6 you use Printer.Print (expression). There is not a Printer
object in VBA. However, there is the Printout method, but that (as far as I
can tell) does not give line by line print control.

No, it prints the current document.
How do you print line by
line in VBA 6.5?

You don't.

You could theoretically write a VB6 ActiveX DLL that you call from VBA and that
passes your information on to Printer.Print

Or you could generate a document in Word, PowerPoint, whatever that looks the
way you want and print from it (Printout method).
 
J

jaf

Hi,
VBA's printout method is designed to send the "print area" to a printer.
There is no print by line control.

The print# suggested by Clif is the only "controllable" method in VBA.

John
 
S

Steve Rindsberg

I havn't tried to do what you're asking ... but having made the jump to
VBA directly from GWBASIC (with a several year gap in between <grin>)
how about VBA's Open and Print # statements?

Another possibility to explore is VBA's OpenAsTextStream Method.

Both of those should work after a fashion.

Problem is that most printers nowadays want to be talked to in their own
dialect ... PCL, PostScript or the like.

You can't always just send them lines of text and expect anything
predictable to happen.

If you have a printer that allows this (or if you want to write your own
PCL/PostScript or are otherwise certifiably "off-meds" <g>) you can write
to the port the printer's connected to or a share name if it's networked.
This works for a PS printer, for example:

Open "\\servername\printer-sharename" For Output As #1
Print #1, "showpage"
Close #1

For a non-PS printer, you'd send your lines of text, then a formfeed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top