document path footer

G

Guest

I have created a VBA script to automatically add the document path to the
footer of every page. When it works, it works OK, but it has the following
problems:

depending on how the document is opened it doesn't always run
the formatting inherits the existing footer formatting instead of
maintaining its' own

does anybody know of a good macro to handle all this, or a 3rd party product
that will do it ?
 
J

Jay Freedman

Hi Steve,

This is a really bad case of reinventing the wheel.

In the template used to create your documents, open the footer area.
On the Header/Footer toolbar, click the AutoText button and select
"Filename and path". That inserts a field that does the job. (Or you
can insert the FileName field through the Insert > Field dialog, and
include the \p switch to show the path.) You can format the field as
you like.

Save the template, and use File > New to create new documents based on
it. Each document will automatically show its path and filename once
it's been saved (although you may have to switch to Print Preview and
back or manually select the field and press F9 to update it).

One caution: If you ever use the Label wizard, don't put anything in
the footer of the Normal.dot template because that will interfere with
the labels.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
G

Guest

Thanks for the info, but unfortunately I don't believe this solution helps
with the 20,000 documents I have already created, many of which have
pre-existing footers.

The requirement is that every word document printed includes a file path
footer. Which means I need some programmatic means to insert this field info
to every document before it is printed
 
J

Jay Freedman

Hi Steve,

If you had mentioned at the beginning that you needed to affect
existing documents, I would have answered differently.

Regarding the problem with the code not running depending on how the
document is opened: I assume you put the code in an AutoOpen macro.
The article at http://support.microsoft.com/?kbid=286310 explains the
behaviors you can expect. A solution may be to get rid of the AutoOpen
macro and instead intercept the FilePrint and FilePrintDefault
commands
(http://www.word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm) to
insert the field just before printing.

Alternatively, you could adapt the code in
http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm to put the field
into every document. If you try this, beware of read-only documents,
password-protected documents, and other pitfalls.

Regarding the formatting: What code are you using to insert the path
now? There are several strategies for fixing the formatting of
inserted text, but which one is easiest depends on what you're already
doing.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

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