The code can be refined if you provide real sample documents which can be tested. The macro can deal with variations but without seeing what the variations are, we don't know what can be expected.
The grouping will fail under some conditions such as the presence of already grouped content or content controls. If you add a aRng.Select line in front of the problem line you will see the current range that is failing so you can examine it to work out why that particular instance failed.
Another option to do troubleshooting would be to firstly apply a character style to all the 'grey' text with a macro and then examine the file to see if all the right things were found. Then the second macro could simply search for that style and group any elements.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
|