|
|
|
|
|
|
Many people access the material from this web site daily. Most just take what they want and run. That's OK, provided they are not selling on the material as their own; however if your productivity gains from the material you have used, a donation from the money you have saved, however small, would help to ensure the continued availability of this resource.
Click the
appropriate button above
to access PayPal. |
|
Show the date a page
was last edited in the page header/footer of that page |
|
| |
It is a frequent requirement for documents, especially
manuals, to record the last date that a particular page was updated.
This is not that easy to do, as Word is not a page layout application
and 'page' is a rather vague concept, created by the flowing of text
within the current margins. However on thinking about the problem, it
should be possible to work around this by taking advantage of the
{Page} field which would enable you to increment docvariable fields,
so you could introduce a docvariable field to the header/footer, which
would allow the same field construction throughout the document. |
|
 |
|
|
This method is not foolproof as it cannot account for
changes in page numbers caused by adding more text than fits on the page
or by removing text which changes the numbering of the pages in the
document. The date applied to the page will be retained on that page
even if the page content has changed by virtue of what went before.
To attempt to overcome that limitation it would be
necessary to insert a section break after each relevant section and use
instead the {Section} field. The field construction below would
be inserted in each header/footer of the document (or the section
header/footers) must be linked to ensure that the field appears in each. |
|
 |
|
|
The above
field constructions will,
when first entered, will show the Createdate
field value as the docvariables will not be present |
|
 |
|
|
When
changes are made to the section, running the
following macro will save the changes, create the docvariable and update
the header to display the following, the date being the date the macro
is run. |
|
 |
|
Note: |
The
cursor must be in the page to be dated before running the macro.
To use the version with page fields rather than
section fields, move the apostrophe from the line
'i =
Selection.Information(wdActiveEndPageNumber)
to the
start of the following line |
| |
Sub
UpDatePageDate()
Dim i As Long
Dim oVars As
Variables
Dim oStory As
Range
Set oVars = ActiveDocument.Variables
'i = Selection.Information(wdActiveEndPageNumber)
i = Selection.Information(wdActiveEndSectionNumber)
oVars("varPage" & i).Value = Format(Date, "d MMM yyyy")
For Each oStory In
ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory
Then
While Not (oStory.NextStoryRange
Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oStory = Nothing
ActiveDocument.Save
End Sub |
| |
If you don't know how to use the macro code see -
http://www.gmayor.com/installing_macro.htm |
|
Note: |
As
fields may not be copied as text, I have included the field construction
in a sample document, c/w the
above macro code.
As the document includes the macro, you may,
depending on how low you have set your macro security, get a security
warning relating to the macros - or the macro may not be enabled.
If you allow the macro to run, when the document is
opened in Word 2007/2010 you will find a command 'Update Page Header' on the
Add-Ins tab of the ribbon. (In earlier Word versions there will be a
floating toolbar containing the same command.) |
|