Headers(wdHeaderFooterPrimary)

S

Senad Isanovic

Need to modify this code. I'd like the logotype to be inserted on the first
page (header) in the document only, not on the other pages. Thaks! /Senad

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
 
D

David-RS

This may not be what you were looking for but instead of writing code to do
this, if you want to have the header on the first page, firstly insert a
section at the top of the document (either new or continuous), then insert
the header and on the header/footer toolbar, click the page setup icon and
goto the layout tab and make sure that the "Different First Page" check box
is selected and also the "Apply to" dropdown shows "This section".

This way you can manipulate the headers and footers for every page if you so
wish. This can be very useful if you want to have chapter headings.

Hope it helps

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top