Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
Add Printer Name to Footer
Hello,
I work for a company that make printable materials for laser, inkjet, solvent inkjet, and other kinds of printers. Several of our test templates are simple Word documents with a particular pattern on them. It becomes very tedious to keep track of them as we have to write the date and printer name on each sheet (sometimes in the 100s). Is there a way to insert the printer name automatically when I click the print button? I have found two articles on using either DocumentBeforePrint and a VBScript for inserting the printer name, but I could not make either work. I'd prefer to have the process remain part of the individual file and not have to edit my normal.dot if possible. Could someone provide me with some detailed instructions on how to accomplish this? I'm not that good with VB, but I can follow instructions. Thanks in advance, |
#2
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
Add Printer Name to Footer
Because there is no field in Word that returns the name of the current
printer, you'll need a macro to insert the date and printer name just before printing. One way to do this is to write a macro in each test template, and name the macro FilePrint. Then when you use the File Print menu item or press Ctrl+P, the macro runs instead of the built-in command. You'd need a second macro named FilePrintDefault to intercept the print button on the toolbar. You said your test templates are simple documents -- I assume that means they're *.doc files. Although you can put a macro into a document, that's a seriously bad idea because Word's security mechanism sees that as a probable virus attack. If you resave your test "templates" as real template (*.dot) files, and store them in the Templates folder, then you can tell Word to trust macros in the templates (that's on the second tab of the Tools Macro Security dialog). A better idea is to put the macro into a module in a template that you store in Word's Startup folder, so it's loaded and available every time you start Word. (The Startup folder is usually at %appdata%\Microsoft\Word\STARTUP, but check the Tools Options File Locations dialog to be sure.) In the same template, also add a toolbar button and/or menu item to run the macro (http://www.word.mvps.org/FAQs/Custom...ToToolbar.htm), leaving the built-in commands untouched. The macro code can be something like this: Sub AddFooterAndPrint() With ActiveDocument ' Put the date and the name of the ' current printer in the main footer. ' This will replace anything that was there before. .Sections(1).Footers(wdHeaderFooterPrimary) _ .Range.Text = Format(Now, "MMMM dd, yyyy") & _ vbTab & Application.ActivePrinter ' Send the document to the printer. .PrintOut Background:=False ' Remove the change. If the document ' didn't need to be saved before, it won't ' need to be saved now. .Undo End With End Sub You can play with the formatting of the footer to get whatever appearance you want. Things get more complicated if the documents have more than one section and the footers are disconnected (not "Same As Previous"). -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. wrote: Hello, I work for a company that make printable materials for laser, inkjet, solvent inkjet, and other kinds of printers. Several of our test templates are simple Word documents with a particular pattern on them. It becomes very tedious to keep track of them as we have to write the date and printer name on each sheet (sometimes in the 100s). Is there a way to insert the printer name automatically when I click the print button? I have found two articles on using either DocumentBeforePrint and a VBScript for inserting the printer name, but I could not make either work. I'd prefer to have the process remain part of the individual file and not have to edit my normal.dot if possible. Could someone provide me with some detailed instructions on how to accomplish this? I'm not that good with VB, but I can follow instructions. Thanks in advance, |
#3
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
Add Printer Name to Footer
The problem is that these files are stored on a network share and used
by many users, so making custom settings for each station isn't really an option. Since I'm also the IT person for our company, I'd really hate to make a template that wasn't completely self contained. The files are currently .doc files, but it doesn't matter to me if they are .dot files if it works. I must admit that macros and VBscript are not my area of strength. I tried to create two macros as listed below, but got "Ambiguous name detected: AddFooterAndPrint". This was just by copying the code below into a SubFilePrint and SubFilePrintDefault headings. Am I doing something wrong or is there something else I need to specify. Thanks again for the help On Apr 12, 12:06 pm, "Jay Freedman" wrote: Because there is no field in Word that returns the name of the current printer, you'll need a macro to insert the date and printer name just before printing. One way to do this is to write a macro in each test template, and name the macro FilePrint. Then when you use the File Print menu item or press Ctrl+P, the macro runs instead of the built-in command. You'd need a second macro named FilePrintDefault to intercept the print button on the toolbar. You said your test templates are simple documents -- I assume that means they're *.doc files. Although you can put a macro into a document, that's a seriously bad idea because Word's security mechanism sees that as a probable virus attack. If you resave your test "templates" as real template (*.dot) files, and store them in the Templates folder, then you can tell Word to trust macros in the templates (that's on the second tab of the Tools Macro Security dialog). A better idea is to put the macro into a module in a template that you store in Word's Startup folder, so it's loaded and available every time you start Word. (The Startup folder is usually at %appdata%\Microsoft\Word\STARTUP, but check the Tools Options File Locations dialog to be sure.) In the same template, also add a toolbar button and/or menu item to run the macro (http://www.word.mvps.org/FAQs/Custom...ToToolbar.htm), leaving the built-in commands untouched. The macro code can be something like this: Sub AddFooterAndPrint() With ActiveDocument ' Put the date and the name of the ' current printer in the main footer. ' This will replace anything that was there before. .Sections(1).Footers(wdHeaderFooterPrimary) _ .Range.Text = Format(Now, "MMMM dd, yyyy") & _ vbTab & Application.ActivePrinter ' Send the document to the printer. .PrintOut Background:=False ' Remove the change. If the document ' didn't need to be saved before, it won't ' need to be saved now. .Undo End With End Sub You can play with the formatting of the footer to get whatever appearance you want. Things get more complicated if the documents have more than one section and the footers are disconnected (not "Same As Previous"). -- Regards, Jay Freedman Microsoft Word MVP FAQ:http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. wrote: Hello, I work for a company that make printable materials for laser, inkjet, solvent inkjet, and other kinds of printers. Several of our test templates are simple Word documents with a particular pattern on them. It becomes very tedious to keep track of them as we have to write the date and printer name on each sheet (sometimes in the 100s). Is there a way to insert the printer name automatically when I click the print button? I have found two articles on using either DocumentBeforePrint and a VBScript for inserting the printer name, but I could not make either work. I'd prefer to have the process remain part of the individual file and not have to edit my normal.dot if possible. Could someone provide me with some detailed instructions on how to accomplish this? I'm not that good with VB, but I can follow instructions. Thanks in advance, |
#4
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
Add Printer Name to Footer
I'm afraid it sounds like you're heading off in the wrong direction. Let me
try to explain a little more of what I'm proposing. Each user has a Startup folder in their profile, by default at C:\Documents and Settings\username\Application Data\Microsoft\Word\STARTUP. Any template that's stored in that particular folder has three important features: 1. It's automatically loaded when Word starts. It will appear in Word's Tools Templates & Add-ins dialog in the "Global templates and add-ins" list. 2. Any macros, toolbars, menu customizations, keyboard shortcuts, and autotext entries in the template will be available in all open documents. 3. If, in the Tools Macro Security Trusted Publishers dialog, you check the option "Trust all installed add-ins and templates", macros in the template won't trigger the security mechanism. One more bit of information: If you use a batch file, a network login file, or something similar to install a template in the Startup folder on each computer, it can use the environment variable %appdata% to represent the C:\Documents and Settings\username\Application Data folder without having to specify the unique username. Write the Copy command to copy the template to %appdata%\Microsoft\Word\STARTUP. If this global template contains the macro I posted before (and don't change its name!!) and a toolbar button that runs the macro, then you don't have to make any changes at all to the documents/templates that already exist. The only change in the standard procedure is to use the toolbar button to print the samples instead of clicking the built-in Print button or the File Print menu item. ~~~~~~~~~~~~ My mention of FilePrint and FilePrintDefault macros -- which would have to be added into each of the existing templates -- was a completely different option than the global template and its macro. If you want to go in that direction, the macro code would be different; you can't just paste in the macro I posted. However, it would be a lot more work for you, and I'd discourage it. It might be a good idea for you to read http://www.word.mvps.org/FAQs/Macros...csIn15Mins.htm and http://www.word.mvps.org/FAQs/Custom...latesStore.htm for some background. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. Solderboy wrote: The problem is that these files are stored on a network share and used by many users, so making custom settings for each station isn't really an option. Since I'm also the IT person for our company, I'd really hate to make a template that wasn't completely self contained. The files are currently .doc files, but it doesn't matter to me if they are .dot files if it works. I must admit that macros and VBscript are not my area of strength. I tried to create two macros as listed below, but got "Ambiguous name detected: AddFooterAndPrint". This was just by copying the code below into a SubFilePrint and SubFilePrintDefault headings. Am I doing something wrong or is there something else I need to specify. Thanks again for the help On Apr 12, 12:06 pm, "Jay Freedman" wrote: Because there is no field in Word that returns the name of the current printer, you'll need a macro to insert the date and printer name just before printing. One way to do this is to write a macro in each test template, and name the macro FilePrint. Then when you use the File Print menu item or press Ctrl+P, the macro runs instead of the built-in command. You'd need a second macro named FilePrintDefault to intercept the print button on the toolbar. You said your test templates are simple documents -- I assume that means they're *.doc files. Although you can put a macro into a document, that's a seriously bad idea because Word's security mechanism sees that as a probable virus attack. If you resave your test "templates" as real template (*.dot) files, and store them in the Templates folder, then you can tell Word to trust macros in the templates (that's on the second tab of the Tools Macro Security dialog). A better idea is to put the macro into a module in a template that you store in Word's Startup folder, so it's loaded and available every time you start Word. (The Startup folder is usually at %appdata%\Microsoft\Word\STARTUP, but check the Tools Options File Locations dialog to be sure.) In the same template, also add a toolbar button and/or menu item to run the macro (http://www.word.mvps.org/FAQs/Custom...ToToolbar.htm), leaving the built-in commands untouched. The macro code can be something like this: Sub AddFooterAndPrint() With ActiveDocument ' Put the date and the name of the ' current printer in the main footer. ' This will replace anything that was there before. .Sections(1).Footers(wdHeaderFooterPrimary) _ .Range.Text = Format(Now, "MMMM dd, yyyy") & _ vbTab & Application.ActivePrinter ' Send the document to the printer. .PrintOut Background:=False ' Remove the change. If the document ' didn't need to be saved before, it won't ' need to be saved now. .Undo End With End Sub You can play with the formatting of the footer to get whatever appearance you want. Things get more complicated if the documents have more than one section and the footers are disconnected (not "Same As Previous"). -- Regards, Jay Freedman Microsoft Word MVP FAQ:http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. wrote: Hello, I work for a company that make printable materials for laser, inkjet, solvent inkjet, and other kinds of printers. Several of our test templates are simple Word documents with a particular pattern on them. It becomes very tedious to keep track of them as we have to write the date and printer name on each sheet (sometimes in the 100s). Is there a way to insert the printer name automatically when I click the print button? I have found two articles on using either DocumentBeforePrint and a VBScript for inserting the printer name, but I could not make either work. I'd prefer to have the process remain part of the individual file and not have to edit my normal.dot if possible. Could someone provide me with some detailed instructions on how to accomplish this? I'm not that good with VB, but I can follow instructions. Thanks in advance, |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I have a color printer, my printer prints a blank page not color | Microsoft Word Help | |||
MS Word to use default printer, not most recently used printer | Microsoft Word Help | |||
Word 2000 - Hyperlinks in footer to TOC with out edit of footer | Microsoft Word Help | |||
Printer Icon for each printer. | Microsoft Word Help | |||
do I need a printer driver for my printer | Microsoft Word Help |