Printing the Filename of Document on Multiple File Select

G

Guest

I have around 50 documents that I need to print. I plan to select all the 50
documents in Windows Explorer and print it from there (right click and hit
print).

I need the filename of each document printed accordingly.

Is there a way I can set the default template of Word (normal.dot) to
include printing of the filename of the document? Or any other suggestion?
 
S

Shauna Kelly

Hi Mike

In this context, I'm not sure what "accordingly" means.

Do you want to produce one document that contains the names of all your
documents? If so, see
How can I print a list of My Documents, or the contents of any folder?
http://www.word.mvps.org/FAQs/General/PrintDocList.htm.

Or, do you want to print the file name within the text of each file (for
example, in the footer)? If so, then you will need to edit each document and
insert the file name. For example, to put the file name in the footer, do
View > Headers and Footers. On the Header and Footer toolbar, click "Switch
between Header and Footer". Now, click Insert AutoText and choose Filename
or Filename and path.

To avoid doing this 50 times, once for each document, you could automate it
using VBA. To give you a start in creating the loop to get to each document
in a folder, see
Find & ReplaceAll on a batch of documents in the same folder
http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

For what it's worth, changing normal.dot or any other template won't have
any effect. Once a document is created, its only remaining link to its
parent template is that the document can access the parent template's
macros, autotexts, toolbars and keyboard shortcuts. For more information
about that, see
What is the relationship between a Word document and its template?
http://www.ShaunaKelly.com/word/templaterelations\index.html

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
G

Guest

Hi Shauna and Mike,

This was very helpful as I'm wanting to do the same thing. I'm wanting to
do what Shauna mentions below and have reviewed and implementing the VBA
script:

"> Or, do you want to print the file name within the text of each file (for
example, in the footer)? If so, then you will need to edit each document and
insert the file name. For example, to put the file name in the footer, do
View > Headers and Footers. On the Header and Footer toolbar, click "Switch
between Header and Footer". Now, click Insert AutoText and choose Filename
or Filename and path.

To avoid doing this 50 times, once for each document, you could automate it
using VBA. To give you a start in creating the loop to get to each document
in a folder, see
Find & ReplaceAll on a batch of documents in the same folder
http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm"

My question is that when the Find/Replace diaglogue box comes up, what do I
enter in the Find/Replace area so that the directory path shows up in the
footer area of each document?

Thanks in advance!
Kristen
 
S

Shauna Kelly

Hi Kristen

In order to write VBA code to put a file name field in the footer of each
document in a folder, you would need to do two things:

1. Work out how to access each file in a folder, open it, and do something
to it.
2. Work out how to insert the filename field where you want it (ie do the
"something" from step 1).

The link to the article at
http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm was intended to provide
an example of how to do step 1; that is how to cycle though all the files in
a folder to do something to them. It won't do step 2.

The code for step 2 would depend on what, exactly, you want to do. Does the
file name have to go in the header or footer? In the first section, last
section or all sections of the document? Or maybe only the first page only?
Should it replace or be added to any existing header or footer. How should
it be formatted? And so on.

Try recording a macro to do what you want. See:
Creating a macro with no programming experience using the recorder

http://www.word.mvps.org/FAQs/MacrosVBA/UsingRecorder.htm

and
How to modify a recorded macro
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm

If you need more help, try one of the Word VBA newsgroups such as
microsoft.public.word.vba.general.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top