I assume you're using something like the solution discussed in this thread:
https://www.msofficeforums.com/word-...numbering.html
To have such macros available to all documents based on a given template (e.g. the Normal.dotm template), simply add the code to that template. I'd advise against using the Normal.dotm template for this, though, as that will impact every document you create - better to create a specific template for all the barcode documents and attach that template to them. Provided the template is stored in a location to which all users of the documents have at least read access, they'll have access to the macros as well.
The only way around manually adding the DOCVARIABLE field would be to write a macro to do it. That macro might sit in the same template as mentioned above and, once the attaching of a particular document is done, which requires opening the document, simply run the macro to add the field to the header.