M
Mark Goddard
Hi,
I've been experiencing some strange problems in my Word
VBA code where when setting the primary header's
LinkToPrevious property to TRUE, it remains at FALSE.
I've managed to reliably replicate something similar in a
simple document...you can create it by following the
below steps:
1) Create a blank document
2) Insert 3 next page section breaks
3) Edit the header in section 3 and turn off the "same as
previous" option.
5) In VBA, type
activedocument.Sections(3).Headers
(wdHeaderFooterPrimary).LinkToPrevious = True
After typing this command, you'll notice section 3 is
still not linked to the previous header, but section 4
has changed from being linked to not being linked.
i.e. it fails every time you try and set LinkToPrevious =
TRUE when the following section also has LinkToPrevious =
True.
The solution here is to put the cursor into section 3 and
type:
selection.Sections.First.Headers
(wdHeaderFooterPrimary).LinkToPrevious = true
This works.
Now, my problem comes when I am (inconsistently) getting
similar behaviour when setting the LinkToPrevious
property of the final section. I can't work out when
this happens or why...does anyone have any ideas?
There's nothing out there that I can find that documents
anything similar.
Cheers,
Mark
I've been experiencing some strange problems in my Word
VBA code where when setting the primary header's
LinkToPrevious property to TRUE, it remains at FALSE.
I've managed to reliably replicate something similar in a
simple document...you can create it by following the
below steps:
1) Create a blank document
2) Insert 3 next page section breaks
3) Edit the header in section 3 and turn off the "same as
previous" option.
5) In VBA, type
activedocument.Sections(3).Headers
(wdHeaderFooterPrimary).LinkToPrevious = True
After typing this command, you'll notice section 3 is
still not linked to the previous header, but section 4
has changed from being linked to not being linked.
i.e. it fails every time you try and set LinkToPrevious =
TRUE when the following section also has LinkToPrevious =
True.
The solution here is to put the cursor into section 3 and
type:
selection.Sections.First.Headers
(wdHeaderFooterPrimary).LinkToPrevious = true
This works.
Now, my problem comes when I am (inconsistently) getting
similar behaviour when setting the LinkToPrevious
property of the final section. I can't work out when
this happens or why...does anyone have any ideas?
There's nothing out there that I can find that documents
anything similar.
Cheers,
Mark