#1
|
|||
|
|||
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. |
#2
|
|||
|
|||
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.
|
#3
|
||||
|
||||
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] |
#4
|
|||
|
|||
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. |
#5
|
||||
|
||||
Quote:
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] |
#6
|
|||
|
|||
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. |
#7
|
||||
|
||||
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] |
Tags |
global, macro |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Need macro to merge files in Word and preserve formatting | Carolin | Word VBA | 3 | 12-14-2014 04:01 AM |
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 |
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 |