#1
|
|||
|
|||
Updating fields in word on save
I have been trying to get create a template that they set the date the file was first created, the date it was last modified and the file path. It looks like I need a macro to do this. I have seen some that update all fields but I don't need the created date to be updated every time. I also am not sure what I need to do so that it updates on save. These are all located in the footer. This is all done in Office 2007. Will it make a difference if these are docm or docx files? Thanks for any help I can get.
|
#2
|
||||
|
||||
You don't need a macro for that - all you need do is add a CREATEDATE field to the template. The CREATEDATE field works with doc, docx and docm files.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks. The date change seems to be working, but the file path is not updating unless done manually.
|
#4
|
||||
|
||||
Are you using a FILENAME field for the file name & path? If so, it should update any time the document is previewed or printed.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
I check with others wanted. It seems it needs to kept up to date not just when printing.
|
#6
|
||||
|
||||
You could try a macro like:
Code:
Sub Document_Open() Application.ScreenUpdating = False With ActiveDocument .Fields.Update .PrintPreview .ClosePrintPreview End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
This runs on open. Is there a way to run it on save? Thanks for the help.
|
#8
|
||||
|
||||
You could rename the macro 'FileSave' (and make a copy that's named 'FileSaveAs' - plus adding the necessary code to deploy the 'Save As' dialogue) to intercept Word's FileSave & FileSaveAs events, but more recent Word versions seem to be deprecating those. However, since the Document_Open event achieves much the same result for any document upon opening, I'd have thought that would be sufficient - the only thing it won't automatically update is the filename when a file is first created or re-saved via Save As, but it will capture that too, the next time the document is opened.
Although Word has 'DocumentBeforeSave' and 'DocumentBeforeClose' application events you could use, programming those is rather more complicated than using the built-in Document_Open event. To see what's involved, check out: http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
OK thanks. I will try it. Thanks for all of the help.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
locking word table cells while auto-updating fields | fingermouse | Word | 6 | 01-14-2015 06:22 AM |
Create automatically updating fields in Word 2010 | tryer | Word | 8 | 01-08-2014 12:39 AM |
Word auto updating fields and changing numbers when saving to PDF | OAEC | Word | 1 | 12-03-2013 08:01 PM |
Word 2013 Fields not updating | awaywithpixie | Word | 1 | 09-10-2013 10:35 AM |
Auto-updating fields in Word 2007? V.V | Ruby Soho | Word | 2 | 11-19-2009 04:35 PM |