PDA

View Full Version : How to add a logo to the header in word



beelte54
03-11-2008, 10:28 AM
I need to add a logo that already exists on the document, to the header of a word document on demand. Below is the following code that I'm using. Its just a sample on who to add text. How to I add a logo in side of a header on word.
Thanks in advance.
Set docActive = objWord.ActiveDocument
objWord.ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

objWord.Selection.Sections(1).Headers(1).Range.Text = "Test"

objWord.ActiveDocument.ActiveWindow.View.SeekView = wdSeekMainDocument

With docActive.PageSetup
.DifferentFirstPageHeaderFooter = False'Set this to false will put text on first page, else will not.
EndWith

fumei
03-12-2008, 11:39 AM
Headers are child objects of the Section. Your code is using Selection to open up the header view. This is not required. You can action any header directly.

Set docActive = objWord.ActiveDocument
docActive.Sections(1).Headers(1).Range.Text = "Test"

will make the range of Primary header of Section 1 = "Test"

"I need to add a logo that already exists on the document, to the header of a word document on demand. "

This seems odd to me. Why would you be transfering a image from in the document to the header, on demand? Could you explain further?

In any case, it is possible with something like:
With ActiveDocument
.InlineShapes(1).Range.CopyAsPicture
.Sections(1).Headers(1).Range.Paste
End With


This would copy InlineShape(1) to the Primary header of Section 1.

fumei
03-12-2008, 11:42 AM
You could also do it by selecting the image in the document, and running:
Selection.InlineShapes(1).Range.CopyAsPicture
ActiveDocument.Sections(1).Headers(1) _
.Range.Paste


This would copy the selected image, and paste into the Primary header of Section 1.