Quote:
Originally Posted by daffy
The comment "better to create a specific template for all the barcode documents and attach that template to them." is a bit foreign to me...how would I do that? Or I'm sure there is a thread somewhere on this.
|
For that, create a new blank document. Add the formatted DOCVARIABLE field to the header. Add the macro to the document. Save the document as a template. Then, for any of the existing documents, go to Developer|Document Template>Templates>Attach then navigate to where the new template is and select it.
The code for adding the DOCVARIABLE field to the header of existing documents varies depending on whether those documents already have header content and what you want to do with whatever's already there. Assuming they don't have any header content that you want to keep, the code for replicating the newly-attached template's header DOCVARIABLE field is as simple as:
Code:
Sub AddDocVarFld()
ActiveDocument.Sections.First.Headers(wdHeaderFooterPrimary).Range.FormattedText = _
ThisDocument.Sections.First.Headers(wdHeaderFooterPrimary).Range.FormattedText
End Sub