Link to home
Start Free TrialLog in
Avatar of posnorm
posnorm

asked on

Printing to a Word Document

This application does a lot of computation of X/Y coordinates, and generates a printed page.  The page is rather complicated, with a lot of graphics and a lot of .CurrentX .CurrentY followed by bits and pieces of text.  Right now, the program does all this directly to the Printer object.

Problem:  How to send this layout as an attachment to an e-mail message.

(1) Print-to-file does not work, since I don't know the printer at the receive end.

(2) Print-to-form then Printing the form results in too much loss of detail.

(3) I could generate a Postscript file (I've done this in the past).

(4) I could generate a pdf file, but it costs too much to buy the Acrobat writer.

(5) So: It occurred to me that perhaps I could print to a Word document, then e-mail that.

How do I "print to a Word document" in the same manner as printing to the Print object? -- Norm
ASKER CERTIFIED SOLUTION
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of justinhemphill
justinhemphill

You can use the Microsoft Word Object Library directly in your VB code.  To do this add a reference from the menu.

Then just create a new instance of this.

To see what code to write, just open up word and record a new macro.  Then do some stuff and go back in to edit the macro and it will show you the code that is required in VB to do the same thing.
Avatar of posnorm

ASKER

Many thanks to both replies.
I'll be sure and get back with my remarks.
I'm always glad to learn something.
-- Norm
justinhemphill, how i didn't think that way!!!
One other option you didn't mention is that you can print to a Picturebox using just about exactly the same code as you have been using to print to the printer object, and then use the SavePicture function to save it out as a .BMP file.  You could then attach this to an e-mail or new word document if you wish.

Just a couple of things, make sure that the picturebox's AutoRedraw property is set to True, and, if you are using graphics functions like PSet or LineTo, then I think that you have to do something like:

Picture1.Picture = Picture1.Image
SavePicture(.......)

As the graphics are drawn into the Image layer of the picturebox, not the picture property (at least I seem to remember something about this)
One slight problem with this approach is that you will lose a lot of quality.  Everything will look very blocky when printed at the other end.  It is basically the same as using print screen key and pasting into MS Paint.
Avatar of posnorm

ASKER

Thank you both for your interest in this problem.
Actually, the primary issue is this, which I am going to re-submit as another question:

A publisher has been scanning the printed page output of my program into Microsoft Publisher.  She would prefer it if I sent her a file she could simply import.

I'm going to research this.  As I said, I'll probably post another question along these lines.

Thanks to both of you again.
Hi, why didn't you use justinhemphill's comment?
By the way, why did you punish me with "B" grade?
Cheers