Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-08-2014, 05:23 PM
macropod's Avatar
macropod macropod is offline Global macro across a number of different word files Windows 7 32bit Global macro across a number of different word files Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
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
  #2  
Old 07-08-2014, 05:34 PM
daffy daffy is offline Global macro across a number of different word files Windows 7 32bit Global macro across a number of different word files Office 2013
Novice
Global macro across a number of different word files
 
Join Date: Jun 2012
Location: Sydney Australia
Posts: 4
daffy is on a distinguished road
Default

Thanks. The header has the company logo, title etc. The word document is a sheet that gets filled in by hand. The serial number section goes on a specific top right hand corner because the sheet gets scanned for archiving. The scanner 'looks' for the specific section to automatically assign and save a file name for that document. We currently have a box to where the user has to affix a serialized label. They too have to be careful to affix it within the printed square and perfectly align otherwise the scanner will not 'read' the barcode. Hence trying to automate this will save at least 30min work per employee per job several times per day.

I will give your suggestions a go and post my result or further questions.
Reply With Quote
Reply

Tags
global, macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
Global macro across a number of different word files Need macro to merge files in Word and preserve formatting Carolin Word VBA 3 12-14-2014 04:01 AM
Global macro across a number of different word files A macro to reveal keyboard shortcuts assigned to global template? New Daddy Word 3 12-17-2013 07:08 AM
Using macro to add variable number of rows to a protected word table Julia Word Tables 1 01-09-2013 06:04 AM
Global macro across a number of different word files How to make an add-in/global macro hanvyj Excel Programming 4 12-14-2012 03:23 AM
Merging word files from excel macro hklein Excel Programming 0 08-05-2011 02:27 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:51 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft