View Single Post
 
Old 07-08-2014, 05:23 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by daffy View Post
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
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote