
Help with handling a run-time error in a macro
Hi there,
I want to change text in a header of one
of sections of a file with the other
sections not affected. I wrote a macro for
the job with the first steps of dislinking
the header of the current section from the
previous section if any and dislinking the
header of the next section from the current
section if any. However, there is a
possibility that there is no next section
after the current section in which I plan
to change text. In that case, the macro goes
to a run-time error even if I have some error
correction in it. OK, here is main part of
the macro (more explantations after the macro).
---------
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
If Selection.HeaderFooter.LinkToPrevious = True Then
Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
LinkToPrevious
ActiveWindow.ActivePane.View.NextHeaderFooter
Else
ActiveWindow.ActivePane.View.NextHeaderFooter
End If
On Error GoTo ProcedureA
If Selection.HeaderFooter.LinkToPrevious = True Then
Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
LinkToPrevious
ActiveWindow.ActivePane.View.PreviousHeaderFooter
Else
ActiveWindow.ActivePane.View.PreviousHeaderFooter
End If
GoTo ProcedureB
---------
In the case that no next secdtion exists,
the macro didn't go to procedureA, it always
gave the run-time error 4605 with debug
highlighting the line before or after else
of the first if statement.
ActiveWindow.ActivePane.View.NextHeaderFooter
Thank you very much for your help in solving
the problem.
Tony Lee
Sent via Deja.com
http://www.*-*-*.com/