Board index » delphi » Add Image to Document Header

Add Image to Document Header


2005-08-29 04:53:13 AM
delphi11
How would I go about adding an image to the header of a Word document? I'm
using the following code to add text to the header. I need an image in the
upper left corner of the header.
WordDocument1.Sections.Item(1).Headers.Item(1).Range.Text:= "text here';
 
 

Re:Add Image to Document Header

Quote
How would I go about adding an image to the header of a Word document? I'm
using the following code to add text to the header. I need an image in the
upper left corner of the header.

WordDocument1.Sections.Item(1).Headers.Item(1).Range.Text:= "text here';
The way to do it in Word is to insert a text box, and put a picture in that.
And then position it. You can do several text boxes (or convert them to
Frames).
As to the actual code, well I normally record a macro to see what the code I
need is. Well actually that is not true in this case, I normally have a
template with things layed out the way the client wants, and I only update
what's necessary. But the record a macro and convert to Delphi is a good
trick. I wish you could do it in Outlook.
Oliver Townshend
 

Re:Add Image to Document Header

The text box method doesn't seem to work properly for me. It is much simpler
to use INSERT | PICTURE | FROM FILE. I recorded the macro and am trying to
convert the basic code to delphi. The ADDPICTURE function is causing me some
problem. The macro code is shown below. the function has 3 properties.
Selection.InlineShapes.AddPicture FileName:= "C:\FILENAME.JPG" _
, LinkToFile:=False, SaveWithDocument:=True
The delphi function has 4 properties. RANGE is the additional property. What
is RANGE? How do I define it?
"Oliver Townshend" <oliveratzipdotcomdotau>writes
Quote
>How would I go about adding an image to the header of a Word document?
>I'm
>using the following code to add text to the header. I need an image in
>the
>upper left corner of the header.
>
>WordDocument1.Sections.Item(1).Headers.Item(1).Range.Text:= "text here';

The way to do it in Word is to insert a text box, and put a picture in
that. And then position it. You can do several text boxes (or convert
them to Frames).

As to the actual code, well I normally record a macro to see what the code
I need is. Well actually that is not true in this case, I normally have a
template with things layed out the way the client wants, and I only update
what's necessary. But the record a macro and convert to Delphi is a good
trick. I wish you could do it in Outlook.

Oliver Townshend

 

Re:Add Image to Document Header

Quote
The delphi function has 4 properties. RANGE is the additional property.
What is RANGE? How do I define it?
A range is a selection of the word document. To properly understand it you
should read books on Word Macro programming. You should at least read the
Word VBA Help section on AddPicture.
But the difference in arguments is interesting. It seems to me that you
have a different version of Word installed as against the version of Word
Delphi knows about. Which is which?
Oliver Townshend
 

Re:Add Image to Document Header

I'm using Word2000 and Delphi 6.
"Oliver Townshend" <oliveratzipdotcomdotau>writes
Quote
>The delphi function has 4 properties. RANGE is the additional property.
>What is RANGE? How do I define it?

A range is a selection of the word document. To properly understand it
you
should read books on Word Macro programming. You should at least read the
Word VBA Help section on AddPicture.

But the difference in arguments is interesting. It seems to me that you
have a different version of Word installed as against the version of Word
Delphi knows about. Which is which?

Oliver Townshend


 

Re:Add Image to Document Header

Quote
I'm using Word2000 and Delphi 6.
But do you have the Word97 Type Library installed, or 2000 (or later)?
Oliver Townshend