> does anyone know how to insert on demand an eps logo in the header of
> a document programatically. I need to be able to insert (or not
> insert) a file in the header based on a flag setting in a useform but
> I cannot seem to get the thing to work. Help would be greatly
> appreciated
Hi Robin
Here are two suggestions:
1. If the logo must remain in a separate file (for instance, if it's updated
frequently), you can use code like this:
Sub AddLogoFromFile()
Dim MyRange As Range
Dim MyInlineShape As InlineShape
Set MyRange = Selection.Sections(1) _
.Headers(wdHeaderFooterPrimary).Range
MyRange.Collapse wdCollapseEnd
Set MyInlineShape = MyRange.InlineShapes.AddPicture _
(FileName:="C:\Graphics\NightWatch.jpg", _
linktofile:=False, savewithdocument:=True, _
Range:=MyRange)
With MyInlineShape
.Height = 0.5 * .Height
.Width = 0.5 * .Width
End With
End Sub
Of course, the FileName should point to your file. As long as it's a file
type that Word has a converter for, this will work. You can insert it as an
InlineShape, or you can change the macro to insert it as a floating Shape --
then you'll want to add statements to the With group to set its .Top and
.Left as well.
Also, you may need to change where MyRange is -- possibly in the first-page
header (change the constant to wdHeaderFooterFirstPage) or in some specific
section independent of the Selection.
2. Less convenient for updating but easier to distribute to others, you can
make an AutoText entry containing the pre-sized logo and store it in the
template on which the document will be based. Then the code looks like this:
Sub AddLogoFromAutoText()
Dim MyRange As Range
Dim ATtemplate As Template
Set MyRange = Selection.Sections(1) _
.Headers(wdHeaderFooterPrimary).Range
MyRange.Collapse wdCollapseEnd
Set ATtemplate = ActiveDocument.AttachedTemplate
ATtemplate.AutoTextEntries("NightWatch").Insert _
where:=MyRange, RichText:=True
End Sub

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Hi Peter, Jay
I'm doing almost the same thing to insert a logo to the
footer section but have problem with removing it could you
please provide a solution for the remove method too.
Thanks,
Leila
>-----Original Message-----
>Hi
>
>does anyone know how to insert on demand an eps logo in the header of a document programatically. I need to be
able to insert (or not insert) a file in the header based
on a flag setting in a useform but I cannot seem to get
the thing to work. Help would be greatly appreciated
>Thank you
>.