Processes in Microsoft 365 for setting up Office apps, redeeming product keys, and activating licenses.
Put the code in an autoopen macro in the template from which the document is created. The code in that macro will run whenever such a document is opened, even one that was created from that template before the macro was created in it.
You probably should create the documents from a template other than the Normal.dotm template as if you put it in the Normal.dotm template, it will run when ALL documents that were created from that template are opened, not only those that are created from your data base.