PDA

View Full Version : Adding Image to header using (Word 2002) VBA?



macamba
04-10-2009, 01:35 AM
Hello,

At the moment I'm creating a template that needs to be used when creating Customer contracts. One of the things I need to do is put the Customers image into the header. I found out I cannot record a macro and access the header (in Word 2002):bug:. So if anyone has an idea how I can solve this, I would appreciate it.

What I was thinking about is:

Start the macro;
Insert an Image into an Image-field;
OR: The macro goes to header;
Use the menu Insert -> Picture/Image -> From file (at which point the macro pauses so you can search, and select the image);
Change the heigth of the image so it is the same as the image height of our companies logo;Macamba

macamba
04-10-2009, 05:18 AM
I think I found it myself :motz2:(after searching the Forum).

If you add the following line to the header:
{INCLUDEPICTURE "\\logo.jpg" \* MERGEFORMATINET}
it works.

The only problem I have is that it only accepts JPG's, and files named logo.jpg.

fumei
04-14-2009, 09:32 AM
"The only problem I have is that it only accepts JPG's, and files named logo.jpg."

No, that is not correct..well it IS correct if you keep the parameter as logo.jpg. The syntax is:

INCLUDEPICTURE filename_including_PATH

Change the parameter.

{INCLUDEPICTURE "c:\\yadda.bmp" \* MERGEFORMAT }

will use the BMP file c:\yadda.bmp

macamba
04-14-2009, 11:09 PM
Thanks. Never would have thought of that alternative.

fumei
04-15-2009, 01:25 PM
It is not an alternative, it is the syntax.