Print String from VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I made a piece of VBA code which results in a string. The next step is to
print this string on paper.

How can I print a string directly from the VBA programm (without first
output it to a cell for example).

Thanks in advance,

JeroenM.
 
Add the text to an empty cell, print, clear the cell.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"JeroenM"
wrote in message
I made a piece of VBA code which results in a string. The next step is to
print this string on paper.

How can I print a string directly from the VBA programm (without first
output it to a cell for example).
Thanks in advance,
JeroenM.
 
Maybe something like:

Option Explicit
Sub testme01()
Open "LPT1:" For Output As #1
Print #1, "Hi There"
Close #1
End Sub
 
Maybe you can install it as LPT1?

or

Open "\\printerid" for output as #1

(untested, I don't have a network printer)
 
But I'd do what Jim suggested:

dim NewWks as worksheet
set newwks = workbooks.add(1).worksheets(1)
with newwks.range("a1")
.value = yourvariablenamehere
.printout
.parent.parent.close savechanges:=false
end with
 
It works, thanks, JeroenM

Dave Peterson said:
Maybe you can install it as LPT1?

or

Open "\\printerid" for output as #1

(untested, I don't have a network printer)
 
Dave,
I wanted to see if this worked but my color laser is on usb
DOT4_001
I tried all variations of that I could think of
 
I've used this in the past when I installed a network printer (at work, under
WinNT, IIRC). I assigned that network printer to lpt1.

I _think_ I used it in Win98 at home. But I couldn't get it to work with WinXP
Home and my HP Officejet USB printer.

I don't have a printer that connects via LPT1 at home, though.
 

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

Back
Top