View Single Post
 
Old 12-03-2023, 07:51 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,993
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

For starters I would say that macros often run into problems if they are progressing forward through a collection of objects and deleting some along the way. The standard practice would be to step backwards through them so that deleting one doesn't change the remainder of the list positions.

However, in this particular macro, there could be considerable other issues. If you find a CC you want to remove, you aren't just deleting that one CC but the entire page. The rest of the page could contain other CCs which again throws off your loop. For that matter, the CCs could be nested so a CC could contain CCs inside it.

The above issues could explain the error in your test file. Without seeing your actual document you are testing on it can be hard to work out the specific problem but that will give you specific areas to look at if you want a solution that fits.

Greg's code is searching for tags that contain the word "Me" but may also contain other words. Did you intend for it to find a tag that was "Me" or did it also need to find CCs with a tag of "Me and Bobby McGee" or "Mean Girls". The former would be found, the latter not by that code. If it was just "Me" by itself in your tags, it would be somewhat easier to restrict the search and simplify the code.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote