Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

Section only revision date

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chad - 11 Feb 2005 22:25 GMT
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.
Doug Robbins - 11 Feb 2005 23:37 GMT
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

Signature

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

>I have a document that has 15+ sections, each one with it's unique footer.
>I
[quoted text clipped - 13 lines]
> 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.
Jezebel - 12 Feb 2005 03:29 GMT
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

> 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.
[quoted text clipped - 50 lines]
>> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.