The key to your problem is the use of the Selection. You don't need it. Work
directly with the Ranges themselves. Separately, don't understand your
concern about error-handling. The error caused if the ShapeRange is empty is
indeed a runtime error, which you can trap or ignore.
Simplest would be something like --
On error resume next
With Selection.Sections(1)
.Headers(wdHeaderFooterPrimary).Range.ShapeRange.Delete
.Headers(wdHeaderFooterEvenPages).Range.ShapeRange.Delete
End With
If you really want to check if the ShapeRange is empty, you can use
If .Headers(wdHeaderFooterPrimary).Range.ShapeRange.Count > 0 then ...
> Can anyone nudge me in the right direction with the following problem,
> please?
[quoted text clipped - 46 lines]
>
> Roderick
Roderick O'Regan - 30 Jul 2005 13:03 GMT
Thanks Jezebel.
Word was crashing when it encountered the ....ShapeRange.Select
command as shown above. Not the runtime error message box.
However, thanks to your suggestion on deleting the Select and
replacing it with Delete does the trick. No crashing. Shapes are
deleted.
Thanks again.
Regards
Roderick
>The key to your problem is the use of the Selection. You don't need it. Work
>directly with the Ranges themselves. Separately, don't understand your
[quoted text clipped - 63 lines]
>>
>> Roderick