Issues with tag of "office word itpro" focus more on general questions of Word desktop app. You issue is related to code which is not supported on Q&A, it's best to ask this question on Word for Developers forum.
I would also remove this tag, and add "not supported".
Thanks for your understanding.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.