Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-07-2014, 09:40 PM
daffy daffy is offline Global macro across a number of different word files Windows XP Global macro across a number of different word files Office 2010 32bit
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 Global macro across a number of different word files

It took a while but I worked it out (after reading/researching your site and others). Currently our staff print serial number labels (60mm x 15mm) that contain the number and a barcode above it then stick these onto a Word generated document. This is very tedious and time consuming. I created a macro where we can now edit the document and the macro is embedded within a shortcut (I used a print symbol in the quick access toolbar). When the user completes the editing, the macro asks the user to input the number of copies required and the starting serial number. The document has the printed sequential serial number with the barcode in sequence.



I do have a question I cannot figure out and have not implemented the above feature to staff yet. We have about 100 or so different documents that require the above process. The serial/barcode location is in exactly the same location on every document (Top right-hand corner in the header section). I want to avoid putting this macro on every document. I would like the user to open any of those documents located on a specific subfolder on the work network. When they hit the 'print' icon (macro shortcut) the input prompts begin. I'm guessing the macro need to reside in that subfolder but not sure how to tackle this issue. I tried looking through global macros across different PCs but could not work it out. Please help. I'm using 2013 but some machines are using 98 and 2007 adn would need it backward compatible if at all possible.
Reply With Quote
  #2  
Old 07-07-2014, 10:54 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

Further to this, for me to make the macro available on any document I need to add the field braces {DOCVARIABLE "CopyNum"} and then specify the font (in this case the barcode) to tell where (location) I want the macro to run/print. Is there a way around having to do this 100+ times? And when the document gets updated or a new one created? The location is "always" in the same location in the header.
Reply With Quote
  #3  
Old 07-08-2014, 03:03 AM
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: 21,962
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

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.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 07-08-2014, 05:13 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 Paul. Yes I read the link...similar. I will definitely try and play with the macro approach to add the field automatically...not an expert by all means, but I think 'recording' the sequence will work.

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.
Reply With Quote
  #5  
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: 21,962
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
  #6  
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
  #7  
Old 07-08-2014, 05:42 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: 21,962
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

In that case, it might be best to insert the DOCVARIABLE field into a textbox (which could be stored in the template header), so it can be added to the existing documents without upsetting whatever's already there. Using a textbox also gives precise control over the positioning.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
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 12:01 PM.


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