View Single Post
 
Old 02-18-2024, 06:15 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I'm not convinced you actually need to skip the TOC, once the macro is run, just update the TOC to refresh it and undo anything the macro might have changed.

You did say that you run the macro multiple times across a document which doesn't make a great deal of sense. I would have thought it makes more sense to run it across a Selection (ie, you select the text you want the macro to work on before running the code). If that was the case, we change the initial scope to work on a selected range
Code:
For Each Para In ActiveDocument.Paragraphs
is changed to
Code:
For Each Para in Selection.Range.Paragraphs
Alternatively, you can get the macro to start working on the content in the file after the TOC (so you exclude any front matter, cover, toc etc from the paragraphs being processed.
eg change that same line to
Code:
  Dim rngSearch As Range
  Set rngSearch = ActiveDocument.Range(ActiveDocument.TablesOfContents(1).Range.End, ActiveDocument.Range.End)
  For Each Para In rngSearch.Paragraphs
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote