Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to create Footer with Macro in Word

761 views
Skip to first unread message

Nabeel

unread,
Jun 10, 2002, 7:52:47 PM6/10/02
to
I need to create a macro so that every Word document has the
filename/filepath and date embedded in the footnotes.
I am having trouble in doing so. If you can provide any assistance, it would
be greatly appreciated. Thanks!


My code is below (VB)
===========
Sub Footer()
'
' Footer Macro
' Macro recorded 10/06/2002 by Name:
'
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveWindow.ActivePane.VerticalPercentScrolled = 48
ActiveWindow.ActivePane.VerticalPercentScrolled = 0
Selection.MoveDown Unit:=wdScreen, Count:=1
ActiveWindow.ActivePane.VerticalPercentScrolled = 49
NormalTemplate.AutoTextEntries("Filename and path").Insert Where:= _
Selection.Range
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Size = 9
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeParagraph
NormalTemplate.AutoTextEntries("Created on").Insert
Where:=Selection.Range
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
End Sub
==================

Nabeel Nasir


PTT, Inc.

unread,
Jun 10, 2002, 7:33:34 PM6/10/02
to
Here is the one I got by recording a macro:

Sub filenameinfooter()
'
' filenameinfooter Macro
' Macro recorded 06/10/02 by PTT, Inc.


'
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _

ActivePane.View.Type = wdOutlineView Or
ActiveWindow.ActivePane.View.Type _
= wdMasterView Then
ActiveWindow.ActivePane.View.Type = wdPageView


End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End If
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:=
_
"FILENAME \p ", PreserveFormatting:=True
Selection.TypeText Text:=vbTab & vbTab
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:=
_
"CREATEDATE \@ ""MMMM d, yyyy""", PreserveFormatting:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

I used the CreateDate field with the above formatting. Assign it to a
toolbar button.

Bill Foley
www.pttinc.com
"Nabeel" <nore...@sympatico.ca> wrote in message
news:uffASnNECHA.1856@tkmsftngp02...

Suzanne S. Barnhill

unread,
Jun 10, 2002, 9:28:54 PM6/10/02
to
You don't really need a macro. Just use the AutoText menu on the Header and
Footer toolbar to insert the "Filename and path" AutoText entry (which is
the { FileName \p } field) in the footer of your template.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word

"Nabeel" <nore...@sympatico.ca> wrote in message
news:uffASnNECHA.1856@tkmsftngp02...

Charles Kenyon

unread,
Jun 11, 2002, 9:34:18 AM6/11/02
to
Hi Nabeel,

I suspect you mean the footer rather than the footnotes. Footers are text
repeated at the bottom of (usually) multiple pages. Footnotes are reference
information linked to particular text.

What you are trying to do here is an example of someone trying to write a
program to do something that is handled very well by a built-in feature of
Word.

You may be better off doing this by setting up a template which has such a
footer in its design and then using that template as the basis for your
future documents where you want the footer. (Note, you will run into
problems if you put such a footer - or any text in the normal.dot template.)

On the header/footer toolbar there is an AutoText button that can help you
with inserting this information using a field.

For more on headers and footers you may want to look at <URL:
http://addbalance.com/usersguide/sections.htm>.

Hope this helps,
--
Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.


"Nabeel" <nore...@sympatico.ca> wrote in message
news:uffASnNECHA.1856@tkmsftngp02...

Rob Solomon

unread,
Jun 11, 2002, 4:54:50 PM6/11/02
to
You say that one will run into problems when inserting
such a footer into the normal.dot template. Some time ago
I had made some modifications (using the Word object model)
to automatically create a footer with the path and
filename and it worked fine when it wasn't crashing the
application. Is that the problem with using normal.dot?
I want to create a network wide solution which users can
override but which is selected by default.

Any thoughts?

Rob Solomon

>> Í{ wÀ ) ©²F$=²Fì'f ìB ==================
>>
>> Nabeel Nasir
>>
>>
>>
>>
>
>
>.
>

Nabeel

unread,
Jun 11, 2002, 8:54:35 PM6/11/02
to
yea thanks everyone for your help... i finally figured it out for Word..
if only i could do the same for Excel.... any suggestions?

Nabeel Nasir
tx!

"Rob Solomon" <r...@prevare.com> wrote in message
news:dc5101c2118a$3ac60450$39ef2ecf@TKMSFTNGXA08...

Beth Melton

unread,
Jun 11, 2002, 11:45:46 PM6/11/02
to
Hi Nabeel,

In Excel it will work a little differently. You need to run the macro
anytime the file name changes it will not automatically update:

Sub FooterFileNameAndPath()
'Can also use .CenterFooter or .RightFooter
'For Header change Footer to Header
ActiveSheet.Pagesetup.LeftFooter = Activeworkbook.FullName
End Sub

Also note that there are also newsgroups for Excel and you'll find the
gurus on Excel hanging out in one of them. They don't frequent the Word
newsgroups very often. :-)
~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Please post replies/further questions to the newsgroup so that all may
benefit.

"Nabeel" <nore...@sympatico.ca> wrote in message

news:OCnreuaECHA.2296@tkmsftngp05...

Cato Antonsen

unread,
Aug 13, 2002, 4:18:23 AM8/13/02
to
Hi,

You say that you will run into trouble if you put any text in the normal.dot
template. Do you mean anywhere in the document or in the footer.

And what problems do you think of?

You see, we have a huge problems with documents beeing corrupted all the
time. And we do have a footer in Normal.dot ...

Sincerely,

Cato Antonsen

"Charles Kenyon" <msnew...@remove.no.spam.addbalance.com> wrote in
message news:OCsxCzUECHA.2284@tkmsftngp02...

Graham Mayor

unread,
Aug 13, 2002, 5:25:08 AM8/13/02
to
You don't want *any* text in normal.dot. Use document templates if you want
footers. The most easily demonstrable problem with having a footer in
normal.dot is when you try to use labels! It might be simpler to create a
document template from your modified normal.dot then rename normal.dot to
oldnormal.dot. You can copy any essentials - like style definitions,
autotext, toolbars and macros from old to new.

--
<>>< ><<> ><<>
Graham Mayor
<>>< ><<> ><<>

"Cato Antonsen" <cato.a...@remoovethis.chello.no> wrote in message
news:ajafd2$832$1...@news.teledanmark.no...

Cato Antonsen

unread,
Aug 13, 2002, 7:59:35 AM8/13/02
to
Yes, but why?

In our firm we don't need any blank documents without any text. ALL our
documents should have a document reference in the footer.

So - if the reason isn't techically, I don't see why we should avoid this...

Sincerely,
Cato Antonsen


"Graham Mayor" <gma...@noonehome.com> wrote in message
news:#gX#usqQCHA.1996@tkmsftngp13...

Suzanne S. Barnhill

unread,
Aug 13, 2002, 9:02:19 AM8/13/02
to
You don't ever print labels? Envelopes?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word

"Cato Antonsen" <cato.a...@remoovethis.chello.no> wrote in message
news:ajasbq$ag2$1...@news.teledanmark.no...

Cato Antonsen

unread,
Aug 13, 2002, 9:56:02 AM8/13/02
to
No, we have templates for such.

Please, let's not bother the others about _how_ we use Word. I just want'ed
to know if there was a _technical_ issue concerning using text (in footer?)
in Normal.dot.

Sincerely,
Cato Antonsen


"Suzanne S. Barnhill" <sbar...@mvps.org> wrote in message
news:u4$nVnsQCHA.1644@tkmsftngp08...

Terry Farrell

unread,
Aug 13, 2002, 1:32:22 PM8/13/02
to
Cato

You can put whatever you want in a footer - text, graphics, formulae,
macros, anything - just don't put it in Normal.Dot and make it the default.
If you want everyone to use a document with customisations, then create a
different template and make Word open to that template by default. Does that
make sense?


--
Terry Farrell - MSWord MVP
See FAQs at http://www.mvps.org/word/index.html

"Cato Antonsen" <cato.a...@remoovethis.chello.no> wrote in message

news:ajb365$16u$1...@news.teledanmark.no...
: No, we have templates for such.

: > > > > > >
: > > > > > >
: > > > > > >
: > > > > > >
: > > > > >
: > > > > >
: > > > >
: > > > >
: > > >
: > > >
: > >
: > >
: >
:
:


Cato Antonsen

unread,
Aug 14, 2002, 1:58:45 AM8/14/02
to
Sorry about repeating myself - and shouting - BUT WHY? You have all said I
should not do this - but not why!

If it's not because it will make documents corrupt and bad -- I don't see
why I should not do this if this is what I want...

Sincerely,
Cato Antonsen

"Terry Farrell" <terryf...@notmsn.com> wrote in message
news:O4GxA9uQCHA.1636@tkmsftngp13...

Cato Antonsen

unread,
Aug 14, 2002, 2:02:09 AM8/14/02
to
I accidentally replied to my own message, when it was your's I should reply
to in the first place. So here it is:

------------


Sorry about repeating myself - and shouting - BUT WHY? You have all said I
should not do this - but not why!

If it's not because it will make documents corrupt and bad -- I don't see
why I should not do this if this is what I want...

Sincerely,
Cato Antonsen


"Terry Farrell" <terryf...@notmsn.com> wrote in message
news:O4GxA9uQCHA.1636@tkmsftngp13...

Suzanne S. Barnhill

unread,
Aug 14, 2002, 9:37:30 AM8/14/02
to
By all means suit yourself. It probably won't do any harm. If it does,
please come back and give us the opportunity to say we told you so. <g>

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word

"Cato Antonsen" <cato.a...@remoovethis.chello.no> wrote in message

news:ajcrjh$497$1...@news.teledanmark.no...

Mark Tangard

unread,
Aug 14, 2002, 2:10:18 PM8/14/02
to

Cato, I think you may just need to do one of two things:

(1) Put your footer in your Normal.dot and wait for the problems.
This is learning the hard way, and chances are the repercussions
will be non-trivial; but sometimes that's how you have to learn.
Unless your users are all quite savvy, expect turmoil and delays
when the system backfires.

(2) Trust us when we say it's a very bad idea. I can't imagine
any office that would want a standard footer on EVERY SINGLE
default-template-based document it produces. Even if nobody
in the office ever needs to rename or delete Normal.dot due
to corruption, etc., it's still foolish to force a footer into
all standard documents unless you truly never produce anything
else. (With a footer in your Normal.dot, you won't be able to
type a short note, a sign/placard, an envelope, etc., without
having to waste time getting rid of the footer.)

Mark Tangard <mtan...@speakeasy.net>, Microsoft Word MVP
Word MVP FAQ: http://www.mvps.org/word
Userform demystification: http://www.speakeasy.org/~mtangard/userforms.html
"Life is nothing if you're not obsessed." --John Waters

Suzanne S. Barnhill

unread,
Aug 14, 2002, 4:22:24 PM8/14/02
to
Not to mention that in Word 2002 you *can't* get rid of the footer entirely;
the empty paragraph remains, possibly displacing other text, unless you
change the footer margin to get it out of the way.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word

"Mark Tangard" <mtan...@speakeasy.net> wrote in message
news:3D5A9D0A...@speakeasy.net...

Cato Antonsen

unread,
Aug 15, 2002, 7:20:18 AM8/15/02
to
Can you *please please please* read what I write!?!?!

I say that we *don't* need to write anything else but what's defined as
templates.

Your say that I shall put my footer in Normal.dot and wait for the problems.
Sorry for yelling - but I have asked this so many times: WHAT PROBLEMS? You
just say there will be problems -- but WHAT PROBLEMS? I assume we're just
using templates and don't need an empty document (Normal.dot without
footers)...

I'm sorry if I seem a litle frustrated. I know you guys and girls help a lot
of people... :-)

Sincerely,
Cato Antonsen


"Suzanne S. Barnhill" <sbar...@mvps.org> wrote in message

news:uCZjMb9QCHA.1992@tkmsftngp10...

Graham Mayor

unread,
Aug 15, 2002, 7:49:25 AM8/15/02
to
If nothing else you are dictating the use of normal.dot by your users.

Normal.dot is a personal scratch pad that holds user personalisations. These
are used when the document template does not dictate any differences. It
should be located locally on the user's PC and should be free from the sort
of control freakery that some companies employ. It should certainly never be
shared, as corruption will bring the whole workforce to a standstill while
you sort it out.

The implication is therefore that you are replacing the users' normal.dot
files (perhaps as they log in). Why do you need to exercise such unnecessary
control over your users?

You have already said that you use templates for your documents - why then
would you need a footer in normal.dot, if you are not going to base any
company documents upon it? Put the footer in the document templates.

You have come here to pick the brains of people who know Word. You have been
advised repeatedly of the inadvisability of adding a footer to normal.dot,
with examples, yet you still want us to justify your way of doing things
against that advice.

You are of course free to take whatever advice you wish, or not as the case
may be. The advice you will continue to get here is DON'T DO IT. It is bad
practice. Getting yourself into a lather is not going to change that.

If you don't like the advice provided then feel free to go elsewhere for it.

--
<>>< ><<> ><<>
Graham Mayor
<>>< ><<> ><<>

"Cato Antonsen" <cato.a...@remoovethis.chello.no> wrote in message

news:ajg2qf$e8p$1...@news.teledanmark.no...

Mark Tangard

unread,
Aug 15, 2002, 1:42:30 PM8/15/02
to

The obvious first-level problem will be that you will have footers on
documents that shouldn't have them. I'm not sure if this was stated
outright; maybe it wasn't because it's so blindingly obvious.

The deeper problem is, as Graham says, you're taking control of each
user's Normal.dot away from the user, which goes against the purpose
of Normal.dot. You will have serious, crippling delays when that
template corrupts, and you'll likely have serious morale problems
in your employees before then. If I worked in an office like that
I'd quit.

You need to read what WE write. Specifically you need to tell us
why, if you use templates for all your documents, you can't just
put the footer in those templates. Is it because you have dozens
of templates? If it is, you can write a macro to open each one
and insert the footer.

Suzanne S. Barnhill

unread,
Aug 15, 2002, 2:24:45 PM8/15/02
to
Putting a footer in Normal.dot wouldn't add it to the templates, anyway. I
don't think he has "dozens of templates." I think they use Normal.dot for
everything.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word

"Mark Tangard" <mtan...@speakeasy.net> wrote in message

news:3D5BE806...@speakeasy.net...

Cato Antonsen

unread,
Aug 16, 2002, 6:31:38 AM8/16/02
to
I HAVE read what you have written, but I guess we think different about what
a "problem" is.

It seems that your definition of a "problem" is a restriction a company puts
on it employees on how they should use Word. This is up to the company to
decide. If the employees don't like it - hey just quit!

My definition, and what I tried to find out in the first place, is if
putting a footer in Normal.dot would cause any TECHNICAL problems like
corrupted documents and such. WHY we would like to use footers in Normal.dot
is in my opinion irrelevant to this case!

To conclude this discussion, my conclusion is that none of you have said
anything that persuades me to think that there is any TECHNICAL reasons not
to have footers in Normal.dot. Am I right?

And yes - we DO use Normal.dot as a template for everything that hasn't a
template. Our policy is that EVERY document shall have its document number
(we're using PowerDocs DMS) in the footer. If anyone want's to make a
document without this footer, they can manually remove it.

Sincerely,
Cato Antonsen

"Mark Tangard" <mtan...@speakeasy.net> wrote in message

news:3D5BE806...@speakeasy.net...

Mark Tangard

unread,
Aug 16, 2002, 11:48:29 AM8/16/02
to

Yes, it certainly is for the company to decide. A company's employees
are also free to decide to leave such a bullheaded company sputtering
in its own dust. Last I checked there was no slavery in Norway.

Do what you like. You will regret it. Maybe not immediately. Nobody
here has any sort of stake in saving you from yourself. It should mean
something to you that every response has advised you against doing what
you want to do. It tells me something that you've refused to answer
questions I've posed to you. And that you're shouting at us as if
we're Microsoft staff (we're not) or as if we're paid to answer your
questions (we're not). I don't think any of us will bother posting
further. I sure won't.

--


Mark Tangard <mtan...@speakeasy.net>, Microsoft Word MVP

Reply ONLY to the newsgroup. Note: MVPs do not work for Microsoft.
MVP FAQ: http://www.mvps.org/word

Terry Farrell

unread,
Aug 16, 2002, 2:20:19 PM8/16/02
to
Removing the footer doesn't release the margin it was taking up.

Terry Farrell


"Cato Antonsen" <cato.a...@remoovethis.chello.no> wrote in message

news:ajikb8$5m2$1...@news.teledanmark.no...
: I HAVE read what you have written, but I guess we think different about

: > > > > > > : > > > >
: > > > > > > : > > >
: > > > > > > : > > >
: > > > > > > : > >
: > > > > > > : > >
: > > > > > > : >
: > > > > > > :
: > > > > > > :
: > > > > > >
: > > > > > >
: > > >
:
:


Cato Antonsen

unread,
Aug 19, 2002, 3:46:19 AM8/19/02
to
I know I should be humble and not shouting - and that you all do a VERY good
job helping people like us. But I get a little frustraded when I feel that
no one really read what I ask about.

Let me tell you an analogy of what I feel this discussion has been like:

In a news-article one of you writes that "Using 16 points Times New Roman as
a heading style is BAD.". Well I off course wonder why, so I write an reply
asking "Why is this bad?". The reply is just "It's BAD, you really won't do
that!". I follow up with "Why is this bad? Will it corrupt my document?".
Again you just say that "you REALLY don't want to use that". This goes on
for some more postings. Repeately I ask you to concretize what you mean with
bad, but again I just get an generalized answer without pointing out any
spesific problem I could get. Those who says that "16 point Times New Roman
headings really looks ugly", has missed what I asked for. If I like 16pt TNR
because it looks good in the context of my company's layout, then let me use
it. What I really wanted to know was if 16pt TNR would make my document
corrupted and permenantly destroyed. See the difference...?

And concerning our company's policy about Normal.dot - no one has complained
and it really works good in our enviroment. Yes, also for the employee...

Lastly, I appoligize for appearing as an ASS***E - this what not my intent.

Sincerely,
Cato Antonsen


"Mark Tangard" <mtan...@speakeasy.net> wrote in message

news:3D5D1ECD...@speakeasy.net...

Terry Farrell

unread,
Aug 19, 2002, 4:46:26 AM8/19/02
to
Cato

TNR at 16pt looks horrible: that's the main reason why you 'don't want to
use'. Some fonts look OK up to 12 or possibly 14 point, but others such as
TNR and Tahoma for example look bloody awful when the point size increases
much beyond 12pt, whereas Gills Sans for example looks excellent at large
sizes, especially in Banner Headlines.

What we are telling you here is that putting a footer into the Global
template is bad because it wreaks havoc by clashing with labels, envelopes,
merges and loads of other functions and if the user doesn't want the footer,
deleting the footer doesn't restore the margin back into the document (some
might consider this a bug, but it is a fact). All you will succeed is
alienating your users and quickly earning the reputation of Gestapo Support.

If the Russians had listened to the experts that had 'been there and done
that', no one would have heard of Chernobyl.

Please, if you want a standard company template, then create one and
possibly change everyone's Word so that it opens into the default company
template rather than normal. Even this isn't really necessary. Just create
the template, install it in the Workgroup folder on the server and tell
everyone that they must use this template for all company documents.

Terry Farrell

"Cato Antonsen" <cato.a...@remoovethis.chello.no> wrote in message

news:ajq7p9$4qg$1...@news.teledanmark.no...
: I know I should be humble and not shouting - and that you all do a VERY

Mark Tangard

unread,
Aug 19, 2002, 6:44:27 AM8/19/02
to

I wasn't gonna say anymore, but the chasm in this logic is just too
large to stay silent right now. Read slowly:

You wrote, today:

> And concerning our company's policy about Normal.dot - no one has
> complained and it really works good in our enviroment.

But in your first post on this thread you said:

> we have a huge problems with documents beeing corrupted all the time

Obviously, something very basic about your Word setup is NOT "really
working good in your environment." And unless you get some sort of
*pleasure* from having documents fall apart on you, then maybe, just
maybe, it would be a good experiment to reverse the policy you have
that goes against the intended use of the most important file in Word.

> Yes, also for the employee...

I don't see how your employees would know the difference between the
setup they have now and the one you apparently have never allowed.

--
Mark Tangard <mtan...@speakeasy.net>, Microsoft Word MVP
Reply ONLY to the newsgroup. Note: MVPs do not work for Microsoft.
MVP FAQ: http://www.mvps.org/word

Userform demystification: http://www.speakeasy.org/~mtangard/userforms.html

Suzanne S. Barnhill

unread,
Aug 19, 2002, 1:58:00 PM8/19/02
to
You're beating a dead horse. Cato doesn't want to make labels, and his
employees are content.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://www.mvps.org/word

"Terry Farrell" <terryf...@notmsn.com> wrote in message
news:#qPMGz1RCHA.2272@tkmsftngp11...

Terry Farrell

unread,
Aug 20, 2002, 2:20:12 PM8/20/02
to
Just like 1984!

Terry

"Suzanne S. Barnhill" <sbar...@mvps.org> wrote in message

news:ugxgwp6RCHA.2648@tkmsftngp08...
: You're beating a dead horse. Cato doesn't want to make labels, and his

0 new messages