Jean-Guy
Wed Dec 08 11:09:34 CST 2004
Senad Isanovic was telling us:
Senad Isanovic nous racontait que :
> I'm talking about button in Word toolbar that will run a macro. The
> code I have so far..
>
Insert a bookmark (Named "logotype" in my example) in the primary header
where you want the logo to appear. Ideally it should be an empty paragraph,
otherwise we might have to modify the code.
'_______________________________________
Sub AddLogo()
Dim HeaderRange As Range
Const BookName As String = "logotype"
Set HeaderRange = ActiveDocument.Sections(1) _
.Headers(wdHeaderFooterPrimary).Range _
.Bookmarks(BookName).Range
With HeaderRange
If .InlineShapes.Count = 0 Then
.Collapse
.InlineShapes.AddPicture _
FileName:="C:\bilder\al425.jpg", _
LinkToFile:=False, SaveWithDocument:=True
Set HeaderRange = HeaderRange.Paragraphs(1).Range
ActiveDocument.Bookmarks.Add BookName, HeaderRange
End If
End With
End Sub
'_______________________________________
'_______________________________________
Sub RemoveLogo()
Dim HeaderRange As Range
Const BookName As String = "logotype"
Set HeaderRange = ActiveDocument.Sections(1) _
.Headers(wdHeaderFooterPrimary).Range _
.Bookmarks(BookName).Range
With HeaderRange
If .InlineShapes.Count > 0 Then
.InlineShapes(1).Delete
Set HeaderRange = HeaderRange.Paragraphs(1).Range
ActiveDocument.Bookmarks.Add BookName, HeaderRange
End If
End With
End Sub
'_______________________________________
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site:
http://www.word.mvps.org