Inserting Shapes into page headers

P

pennyg

I have a macro to insert shapes into page headers but it
doesn't always place the shape into the expected header.
The macro loops through each section, checks whether the
firstpage header is different and if so places the shape
into both the primary and first pages otherwise it is just
placed into the first header. Example of placing into the
Primary header is:

Set shapename = ActiveDocument.Sections(sectNo).Headers
(wdHeaderFooterPrimary).Shapes. _
AddTextEffect(msoTextEffect2, wording, "Arial
Black", 36#, msoFalse, msoFalse, 248.75, 112.7)

I will get both the primary and first page text appearing
in the same header, it seems to vary which header it will
use.

Can anyone suggest a reason for this?

FYI - the same code will insert a text box into a document
correctly taking into account second breaks etc.

Thanking you in advance
P.
 
P

Peter Hewett

Hi Penny

Check out the LinkToPrevious property, this needs to be set to False. As an
example say we have a document with 2 sections, the following code is
perfectly valid but each statement will actually update the Primary Header of
BOTH sections if LinkToPrevious is True:

ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary) _
.Range.InsertAfter "Hello"
ActiveDocument.Sections(2).Headers(wdHeaderFooterPrimary) _
.Range.InsertAfter " World"

To test this out create a 3 page document with a NextPage Section break at
the end of the first page. Don't do anything to the headers and the default
will be LinkToPrevious = True. Run the above code. Hopefully this is the
cause of your problems. If I've missed the mark please post again.

HTH + Cheers - Peter
 
P

pennyg

Hi Peter

thanks for you idea but unfortunately its not the
problem. The code is set to test whether it is linked to
previous and if so it skips that header if not it attempts
to insert the wordArt. As mentioned this is perfect if I
am inserting a text box and will insert into both the
first and primary headers (if the first is needed). Once
I try to insert WordArt I get the problem. The code
tests whether the first page header is different and if so
inserts the wordart into headerFirst as well as
headerPrimary. If they are not different then it only
inserts into Header primary. For each section it checks
whether the header is linked to previous and if not
attempts to insert the wordart box.

Thanks again
Penny
 
P

Peter Hewett

Hi Penny

We're shooting in the dark. Post your code and an explanation of a SIMPLE
document structure where the code fails. The document structure information
we need would be for each Section the Header/Footer definition: Different
First Page, Different Odd/Even Pages and whether a particular Header is
linked to previous. In other words something simple we can recreate without
hours of effort!

Cheers - Peter
 

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