Section only revision date

C

Chad

I have a document that has 15+ sections, each one with it's unique footer. I
am using section breaks (insert-break-section break next page). What I want
to do is include auto text that adds a date in the footer when I last updated
that particular section. So if sections 1 thru 15 were last updated on
2/5/05 and then I made a change with section 12 on 2/12/05 I want the footer
for section 12 to say 2/12/05 and the other section's footers to remain
2/5/05.

I understand there is no way built into Word that allows me to do this and
that a macro is required. I have experience with Excel macros, but not word
and have no idea how or where to start. I am using word 2000, but can
upgrade to the most current if I need to.
 
D

Doug Robbins

I'm not sure that you would not be better off doing it manually and there
are numerous ways in which it could be done.

One way would be to insert a {DocVariable varSection#} field in each footer
where # is the number of the section.

Then you could use a macro such as:

Dim varname As String, i As Long
varname = "varSection" & InputBox("Enter the number of the Section", "Insert
Date into Section", "")
ActiveDocument.Variables(varname).Value = Format(Date, "MMMM d, yyyy")
For i = 1 To ActiveDocument.Sections.Count
ActiveDocument.Sections(i).Footers(wdHeaderFooterPrimary).Range.Fields.Update
Next i

Before running that however, when you first create the document, you should
run a macro that contains

Dim i as Long, varname as string
For i = 1 to ActiveDocument.Sections.Count
varname = "varSection" & i
ActiveDocument.Variables(varname).Value = Format(Date, "MMMM d, yyyy")
Next i

To initially create the document variables. If that is not done any
docvariable fields for which there is no variable created will display an
error message.

If you do not want to start with a date in each variable, just use

ActiveDocument.Variables(varname).Value = " "

in the above to create a variable that just contains a space

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
J

Jezebel

I'm not sure that you'd want to try this unless you like experimenting, but
you could automate this way --

1. Track revisions in the document (ActiveDocument.TrackRevisions = true,
set by default or when the document opens)

2. When you want to update or on save,
- Create an array of DateValues, one for each section: Dim pDates(1 to
Document.Sections.Count) as date
- Iterate the revisions collection.
- Check which section the revision is in:
Revision.Range.Information(wdActiveEndSectionNumber)
- Check if it's the latest revision for that section: Revision.Date >
pDates(Section) and if so update
- Update each of the DocVariables with the values in pDates()
- Update fields in footers
 

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