Solved

Printing to a Word Document

Posted on 2002-04-05
8
206 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:posnorm
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 100 total points
ID: 6922336
Why don't you use a richtextbox control and save the contents to .rtf file.
That control has a built-in method to save the file.
0
 
LVL 1

Expert Comment

by:justinhemphill
ID: 6922799
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.
0
 

Author Comment

by:posnorm
ID: 6922964
Many thanks to both replies.
I'll be sure and get back with my remarks.
I'm always glad to learn something.
-- Norm
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6923112
justinhemphill, how i didn't think that way!!!
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6929559
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)
0
 
LVL 1

Expert Comment

by:justinhemphill
ID: 6931949
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.
0
 

Author Comment

by:posnorm
ID: 6935952
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.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6936755
Hi, why didn't you use justinhemphill's comment?
By the way, why did you punish me with "B" grade?
Cheers
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

773 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