View Single Post
 
Old 02-19-2024, 07:26 AM
Shelley Lou Shelley Lou is offline Windows 10 Office 2016
Expert
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA Adding missing Punctuation to end of Paragraphs

Hi Andrew, thank you for your suggestions, I've tinkered about with both the On Selection method and the Auto .Select method – I think I prefer the Auto method, especially for small documents but may have to result to the On Selection for larger documents as these may contain Equations.

I've tested the code on a document that contained a TOC and it worked well, however, I then tested the code on a different document that did not contain a TOC but it threw up an Error 5941 'The requested member of the collection does not exist'. Could we get the code to look for TOC but if not present go to next as not all documents will contain a TOC.
Code:
Set rngSearch = ActiveDocument.Range(ActiveDocument.TablesOfContents(1).Range.End, ActiveDocument.Range.End)
Would it also be possible to get the code to look for punctuation already present before the last character, e.g. a square bracket or footnote etc. so that the code doesn't insert additional punctuation. I really appreciate the time you have taken to help me on this.

double punc image.JPG
Reply With Quote