A family of Microsoft word processing software products for creating web, email, and print documents.
I created a small test document:
I ran your macro as posted, without any modification:
It appears to work, so perhaps there is something in your document that the code doesn't take into account.
If you cannot find what causes the problem yourself, could you make a document available that demonstrates the problem?