R
Roderick O'Regan
Can anyone nudge me in the right direction with the following problem,
please?
I have a document with odd and even pages.
Every page has a header graphic.
I need to insert a landscape page anywhere after page 1 - this I can
manage OK.
Now I need to go into both the odd and even headers of the landscape
section.
I insert a page break command to display both odd and even pages of
the new section.
Then I go to each of the headers and unlink them from the previous.
Next I need to check if there is a shape range in both the odd and
even headers and delete it. I think I might be able to use the
following commands:
With Selection
..Sections(1).Headers(wdHeaderFooterPrimary).Range.ShapeRange.Select
.Delete
..Sections(1).Headers(wdHeaderFooterEvenPages).Range.ShapeRange.Select
.Delete
End With
And here is the problem:
If, for some reason there isn't a ShapeRange in one of the headers
then one of the commands show above causes Word to crash and therefore
I don't think an On Error statement is appropriate as it's not a
runtime error.
What I am trying to compose is a statement which says "If there is a
ShapeRange in the Primary Header of this section then delete it.
Otherwise, go to the Even Pages of the section header, check if there
is a shape range there and delete it"
Easy to write in pseudo code but I'm baffled on how to write it in
VBA!
Any help on this, please?
Regards
Roderick
please?
I have a document with odd and even pages.
Every page has a header graphic.
I need to insert a landscape page anywhere after page 1 - this I can
manage OK.
Now I need to go into both the odd and even headers of the landscape
section.
I insert a page break command to display both odd and even pages of
the new section.
Then I go to each of the headers and unlink them from the previous.
Next I need to check if there is a shape range in both the odd and
even headers and delete it. I think I might be able to use the
following commands:
With Selection
..Sections(1).Headers(wdHeaderFooterPrimary).Range.ShapeRange.Select
.Delete
..Sections(1).Headers(wdHeaderFooterEvenPages).Range.ShapeRange.Select
.Delete
End With
And here is the problem:
If, for some reason there isn't a ShapeRange in one of the headers
then one of the commands show above causes Word to crash and therefore
I don't think an On Error statement is appropriate as it's not a
runtime error.
What I am trying to compose is a statement which says "If there is a
ShapeRange in the Primary Header of this section then delete it.
Otherwise, go to the Even Pages of the section header, check if there
is a shape range there and delete it"
Easy to write in pseudo code but I'm baffled on how to write it in
VBA!
Any help on this, please?
Regards
Roderick