Macro to insert / update footer 
Author Message
 Macro to insert / update footer

Hello,

At work we've implemented a new file structure. To help our users file and
retrieve their document we would like to create a macro in their normal.dot
under 'AutoClose' (activates when they close a document) so it inserts the
filename and path (using AutoText) into the footer.

I started this by simply recording a macro: View - Header & Footer, switch
to footer, Insert - AutoText - Path & Filename.
This works fine, except when they re-open the document to edit something,
upon closing the document, another Path & Filename is inserted.
A cheap way around this is to Edit - Select All once into the footer, so
inserting the path again will overwrite the original one. But the problem
with this is, if the user wants to Page Numbering or anything else in their
footer also, this will also be overwritten.

I'd like a macro that says, if there isn't a Path & Filename in the footer,
then insert one. If there is, then just update it (not insert another one).
I've tried some VBA, using an IF statement to detect whether the Path &
Filename is already there, but my skills in VBA are rather basic.

Any help on this would be greatly appreciated by a stuck IT Unit and a
building of users!

Regards,

Mark

Suffolk, England.



Thu, 08 Jul 2004 01:36:51 GMT  
 Macro to insert / update footer
The range you need to check out is probably

activedocument.sections(1).Footers(wdHeaderFooterPrimary).Range

if iterate through the .fields in that range, and look for one of the
right type to set a flag, we have the basic logic needed for the task.

Does that help?

On Sat, 19 Jan 2002 17:36:51 -0000, "Stranger_UK"

Quote:

>Hello,

>At work we've implemented a new file structure. To help our users file and
>retrieve their document we would like to create a macro in their normal.dot
>under 'AutoClose' (activates when they close a document) so it inserts the
>filename and path (using AutoText) into the footer.

>I started this by simply recording a macro: View - Header & Footer, switch
>to footer, Insert - AutoText - Path & Filename.
>This works fine, except when they re-open the document to edit something,
>upon closing the document, another Path & Filename is inserted.
>A cheap way around this is to Edit - Select All once into the footer, so
>inserting the path again will overwrite the original one. But the problem
>with this is, if the user wants to Page Numbering or anything else in their
>footer also, this will also be overwritten.

>I'd like a macro that says, if there isn't a Path & Filename in the footer,
>then insert one. If there is, then just update it (not insert another one).
>I've tried some VBA, using an IF statement to detect whether the Path &
>Filename is already there, but my skills in VBA are rather basic.

>Any help on this would be greatly appreciated by a stuck IT Unit and a
>building of users!

>Regards,

>Mark

>Suffolk, England.

Steve Hudson, Word Heretic
HDK List MVP



Thu, 08 Jul 2004 02:16:51 GMT  
 Macro to insert / update footer
We run a similar file structure to identify documents that uses the file
name in the footer.  We have inserted the file name field (and path if
required) into the footer of the template(s).  Every time a document is
created and saved using the template, the file name is updated in the footer
automatically.

This is a simple solution but works well for us!

Regards

Carol


Quote:
> Hello,

> At work we've implemented a new file structure. To help our users file and
> retrieve their document we would like to create a macro in their
normal.dot
> under 'AutoClose' (activates when they close a document) so it inserts the
> filename and path (using AutoText) into the footer.

> I started this by simply recording a macro: View - Header & Footer, switch
> to footer, Insert - AutoText - Path & Filename.
> This works fine, except when they re-open the document to edit something,
> upon closing the document, another Path & Filename is inserted.
> A cheap way around this is to Edit - Select All once into the footer, so
> inserting the path again will overwrite the original one. But the problem
> with this is, if the user wants to Page Numbering or anything else in
their
> footer also, this will also be overwritten.

> I'd like a macro that says, if there isn't a Path & Filename in the
footer,
> then insert one. If there is, then just update it (not insert another
one).
> I've tried some VBA, using an IF statement to detect whether the Path &
> Filename is already there, but my skills in VBA are rather basic.

> Any help on this would be greatly appreciated by a stuck IT Unit and a
> building of users!

> Regards,

> Mark

> Suffolk, England.



Thu, 08 Jul 2004 05:19:48 GMT  
 Macro to insert / update footer
Thank you Steve and Carol. Another reader suggested simply including the
filename field in the template(s). I think I was rather one-track minded in
thinking I need a macro to do the job. I think this solution will work fine!

Cheers,

Mark.


Quote:
> We run a similar file structure to identify documents that uses the file
> name in the footer.  We have inserted the file name field (and path if
> required) into the footer of the template(s).  Every time a document is
> created and saved using the template, the file name is updated in the
footer
> automatically.

> This is a simple solution but works well for us!

> Regards

> Carol



> > Hello,

> > At work we've implemented a new file structure. To help our users file
and
> > retrieve their document we would like to create a macro in their
> normal.dot
> > under 'AutoClose' (activates when they close a document) so it inserts
the
> > filename and path (using AutoText) into the footer.

> > I started this by simply recording a macro: View - Header & Footer,
switch
> > to footer, Insert - AutoText - Path & Filename.
> > This works fine, except when they re-open the document to edit
something,
> > upon closing the document, another Path & Filename is inserted.
> > A cheap way around this is to Edit - Select All once into the footer, so
> > inserting the path again will overwrite the original one. But the
problem
> > with this is, if the user wants to Page Numbering or anything else in
> their
> > footer also, this will also be overwritten.

> > I'd like a macro that says, if there isn't a Path & Filename in the
> footer,
> > then insert one. If there is, then just update it (not insert another
> one).
> > I've tried some VBA, using an IF statement to detect whether the Path &
> > Filename is already there, but my skills in VBA are rather basic.

> > Any help on this would be greatly appreciated by a stuck IT Unit and a
> > building of users!

> > Regards,

> > Mark

> > Suffolk, England.



Thu, 08 Jul 2004 16:57:38 GMT  
 Macro to insert / update footer
I wouldn't mess with the user's normal.dot. Why not use an add-in triggering
to the close event, instead.

The AutoText is really fields, why not skip the use of AutoText and simply
add the fields directly. This way if there is any problem with access to the
AutoText, the fields will still be inserted and work.

You shouldn't need to update the fields once they are inserted. That is the
purpose of using fields (whether inserted directly or through AutoText).

If you need to post in more than one usergroup, please put both newsgroups
in the header of one message instead of posting two duplicate messages. It
makes a difference in ease of use.
--
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.


Quote:
> Hello,

> At work we've implemented a new file structure. To help our users file and
> retrieve their document we would like to create a macro in their
normal.dot
> under 'AutoClose' (activates when they close a document) so it inserts the
> filename and path (using AutoText) into the footer.

> I started this by simply recording a macro: View - Header & Footer, switch
> to footer, Insert - AutoText - Path & Filename.
> This works fine, except when they re-open the document to edit something,
> upon closing the document, another Path & Filename is inserted.
> A cheap way around this is to Edit - Select All once into the footer, so
> inserting the path again will overwrite the original one. But the problem
> with this is, if the user wants to Page Numbering or anything else in
their
> footer also, this will also be overwritten.

> I'd like a macro that says, if there isn't a Path & Filename in the
footer,
> then insert one. If there is, then just update it (not insert another
one).
> I've tried some VBA, using an IF statement to detect whether the Path &
> Filename is already there, but my skills in VBA are rather basic.

> Any help on this would be greatly appreciated by a stuck IT Unit and a
> building of users!

> Regards,

> Mark

> Suffolk, England.



Thu, 08 Jul 2004 03:24:47 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Macro to insert / update footer

2. EZ - Need macro to insert path into footer

3. Insert AutoText in Footer via Macro

4. Updating fields: footer doesn't update right

5. Align only last-inserted paragraph in footer

6. Inserting footer

7. Insert text and date in Footer/Header with VBA

8. Problem inserting footers

9. How to insert txt in a footer w/o deleting existing text

10. Inserting page numbers in footer with word automation

11. oledb: foxpro index file not updating after inserts and updates

12. Inserting headers and footers in richtextbox control

 

 
Powered by phpBB® Forum Software