Are you sure which document the code is running against? You're using a mixture of Selection, ThisDocument and ActiveDocument calls and I can't tell from what you've posted if they're all referencing the same document.
You might want to check out:
https://www.msofficeforums.com/word-...html#post87989