If the code is running into memory issues but appearing to do the right thing then you could maybe modify the counter to exit the sub after 50 replacements.
If the resulting doc is fine then save the doc and run it again and see if that is also OK.
After a couple of successful runs, you could change the number to 100 or higher. Starting the macro 7 times is a whole lot better than never getting a result.
Perhaps throwing in a Save would clear the memory instead of doing the DoEvents.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
|