C
ckxplus
I've got a document with 3 table of contents levels and I want to
reduce this to 1 level. I know that the table of contents is defined
byTC fields in 3 consecutive paragraphs. So I want to replace the TC
field in the first paragraph by the new text, delete the TC fields in
the next 2 paragraphs, then move on to the next TC field.
It's the last part I can't figure out. I can get the contents of the
first TC field using:
Dim aRange As Range
Set aRange = ActiveDocument.GoTo(what:=wdGoToField,
Which:=wdGoToFirst, Name:="TC")
I can then make the modifications, but how would I move on to the next
TC field? I can use:
Set aRange = ActiveDocument.GoTo(what:=wdGoToField, Which:=wdGoToNext,
Name:="TC")
But how can I test if the GoTo was successful? Is there a property of
aRange I can use to loop through all the TC fields of the document
until all have been modified or deleted?
Because I'm going to delete fields, I can't use the "for each fld in
activedocument.fields" approach. Any other suggestions?
Advance thanks for any help,
John Hendrickx
reduce this to 1 level. I know that the table of contents is defined
byTC fields in 3 consecutive paragraphs. So I want to replace the TC
field in the first paragraph by the new text, delete the TC fields in
the next 2 paragraphs, then move on to the next TC field.
It's the last part I can't figure out. I can get the contents of the
first TC field using:
Dim aRange As Range
Set aRange = ActiveDocument.GoTo(what:=wdGoToField,
Which:=wdGoToFirst, Name:="TC")
I can then make the modifications, but how would I move on to the next
TC field? I can use:
Set aRange = ActiveDocument.GoTo(what:=wdGoToField, Which:=wdGoToNext,
Name:="TC")
But how can I test if the GoTo was successful? Is there a property of
aRange I can use to loop through all the TC fields of the document
until all have been modified or deleted?
Because I'm going to delete fields, I can't use the "for each fld in
activedocument.fields" approach. Any other suggestions?
Advance thanks for any help,
John Hendrickx