Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding ^13 does not work with \h in ToC

Status
Not open for further replies.

SunD3

Technical User
Oct 30, 2008
4
US
I wrote a vba macro to remove the words Table and Figure from a Table of Figures ToC that has ?already been updated and to drop the period space space and replace it with a tab. It works, but I ?would like to add ^13 (paragraph mark) before Table or Figure into the code so that the paragraph ?mark is selected along with Table or Figure, but the macro does not work if the ToC contains a \h ??(hyperlink). Our ToCs now require hyperlinks. Does anyone know what needs to change in the code to ?be able to find the paragraph mark with the words Table or Figure? ?

The ^13 works with no \h in the ToC: ^13(Table )([0-9][0-9])(. )(*^t)?

Sub FND_TableSp_RPLC_Blank_WithSlashH()?

? Selection.SelectCell
? Selection.Find.ClearFormatting
? Selection.Find.Replacement.ClearFormatting
? With Selection.Find
? .Text = "(Table )([0-9])(. )(*^t)"?
? .Replacement.Text = "\2^t\4"?
? .Forward = True?
? .Wrap = wdFindStop?
? .Format = True?
? .MatchCase = False?
? .MatchWholeWord = False?
? .MatchAllWordForms = False?
? .MatchSoundsLike = False?
? .MatchWildcards = True?
? End With
? Selection.Find.Execute Replace:=wdReplaceAll
? ?
? Selection.SelectCell

? Selection.Find.ClearFormatting
? Selection.Find.Replacement.ClearFormatting
? With Selection.Find
? .Text = "(Table )([0-9][0-9])(. )(*^t)"?
? .Replacement.Text = "\2^t\4"?
? .Forward = True?
? .Wrap = wdFindStop?
? .Format = True?
? .MatchCase = False?
? .MatchWholeWord = False?
? .MatchAllWordForms = False?
? .MatchSoundsLike = False?
? .MatchWildcards = True?
? End With
? Selection.Find.Execute Replace:=wdReplaceAll
End Sub


 
Hi SunD3,

Unless you convert the TOC to plain text (which also kills the hyperlinks), you're wasting your time - the next time you update the TOC, everything you've deleted will be back. If you don't want certain things appearing in the TOC, then apply the correct Style formats in the body of the document and the appropriate switches in the TOC field.

Cheers
Paul Edstein
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top