Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing a string in VBA

Status
Not open for further replies.

random260

Programmer
Mar 11, 2002
116
US
Apparently this isn't as simple as I thought it would be... I want to print the contents of a string (strstuff). I THOUGHT that

printer.print strstuff

would work, but I get the error
runtime error 424
object required

do I have to define the printer somehow beofre I can print?

Thanks
 
Which application are you using? Word, Excel, Access?

If it's Word, you need something a bit more like
Code:
ActiveDocument.TypeText Text:= strstuff
ActiveDocument.PrintOut

This will type your string onto the doc page and print it out to the default printer.

Cheers,
Dave

Probably the only Test Analyst on Tek-Tips

animadverto vos in Abyssus!

Take a look at Forum1393 & sign up if you'd like
 
That's unacceptable, because the active document has stuff on it already - strstuff is actualy some things I "harvested" from the active doc - and it can't have naything else put on it. Yes, it is word.
 
Hi random260,

There is no native print capacity in VBA. Can you not create a temporary document to hold your string, and print the document, deleting it afterwards?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top