Solved

Printing to a Word Document

Posted on 2002-04-05
8
204 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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6923112
justinhemphill, how i didn't think that way!!!
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now