A
Anne Schouten
I made a macro to place a logo on each header of a Word document.
The logo is a jpg-file and stored as an autotext (Logo) in the template.
As a document can have several sections I only place a logo as the header is
not linked to the previous one.
The (shortened) code is:
bytNumberOfSections = ActiveDocument.Sections.Count
For n = 1 To bytNumberOfSections
ActiveWindow.ActivePane.View.NextHeaderFooter
If Selection.HeaderFooter.LinkToPrevious = False Then
.TypeText Text:= "Logo"
.Range.InsertAutoText
End If
Next
With Word 2003 I encounter the following problems:
1.. With more then 1 section on a page he does not go to the next Header,
so the last sections do not have a logo (if the header is not linked to the
previous one)
2.. If I run the macro with F8 the rest goes fine, but if I just run the
macro (F5) he does not always react on the statement:
If Selection.HeaderFooter.LinkToPrevious = False Then
and insert a second logo on top of the other one when the header
is linked to the previous header.
If I add to the code some lines inserting text and deleting the
inserted text it works alright, but I do not think that is an very elegant
solution.
This second problem (by running a macro he skips some lines) I had also in
other macro's in Word 2003 (not in Word 2000).
I do hope someone can give me an answer for these problems.
Anne
The logo is a jpg-file and stored as an autotext (Logo) in the template.
As a document can have several sections I only place a logo as the header is
not linked to the previous one.
The (shortened) code is:
bytNumberOfSections = ActiveDocument.Sections.Count
For n = 1 To bytNumberOfSections
ActiveWindow.ActivePane.View.NextHeaderFooter
If Selection.HeaderFooter.LinkToPrevious = False Then
.TypeText Text:= "Logo"
.Range.InsertAutoText
End If
Next
With Word 2003 I encounter the following problems:
1.. With more then 1 section on a page he does not go to the next Header,
so the last sections do not have a logo (if the header is not linked to the
previous one)
2.. If I run the macro with F8 the rest goes fine, but if I just run the
macro (F5) he does not always react on the statement:
If Selection.HeaderFooter.LinkToPrevious = False Then
and insert a second logo on top of the other one when the header
is linked to the previous header.
If I add to the code some lines inserting text and deleting the
inserted text it works alright, but I do not think that is an very elegant
solution.
This second problem (by running a macro he skips some lines) I had also in
other macro's in Word 2003 (not in Word 2000).
I do hope someone can give me an answer for these problems.
Anne