Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Field 'User Address' in Footer - update on open (Word 97 or 2000)

    I am sure this question has been asked a million times. Forgive me for asking again!

    Keep in mid that many of the users are either computer illiterate or computer phobic. Anything they have to do must be SIMPLE and once only.

    I have a letterhead / form on our network that has and address in the footer. This address changes according which office / location the staff member is located at. I thought I was pretty clever in working out that I can put in a field {useraddress *mergeformat}. The user need only enter their own address details in ToolsOptionsUser Info - User Address.

    It appears to almost work. Unfortunately it seems to stay with the address of the last user. To update the address, I have to update it using the right click update field method - I want it to update automatically on opening the document.

    Can anyone help me here?

    Kerry

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Field 'User Address' in Footer - update on open (Word 97 or 2000)

    Most fields are updated automatically when the document is print previewed or printed. If you want fields to be updated when the document is opened, you can create an AutoOpen macro in the template to do this:

    Sub AutoOpen()
    Dim aStory As Range
    Dim aField As Field
    For Each aStory In ActiveDocument.StoryRanges
    For Each aField In aStory.Fields
    aField.Update
    Next aField
    Next aStory
    End Sub

    See WD2000: How to Automatically Update Fields for more info (the above macro is from this MSKB article.)

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Field 'User Address' in Footer - update on open (Word 97 or 2000)

    Two footnotes to the code Hans provided:

    1. <LI>If you only want this code to run when a new document is created and not every time it is opened (perhaps by someone in a different office, causing the document to change in an undesirable way), change the macro name to AutoNew rather than AutoOpen.

      <LI>If you later find yourself developing a multiple section template, don't be surprised that the code snippet fails to update the headers and footers in section 2 and higher if they are not linked to the headers and footers in section 1. You have to add more code to check all the sections. (Now someday you can answer someone else when this question pops up!)
    Hope your users find this as easy as it seems.

  4. #4
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Field 'User Address' in Footer - update on open (Word 97 or 2000)

    Thankyou Hans.

  5. #5
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Field 'User Address' in Footer - update on open (Word 97 or 2000)

    Good points. I will keep this in mind.

    Thankyou

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Field 'User Address' in Footer - update on open (Word 97 or 2000)

    Another footnote:

    Hans' code won't update fields in Word shapes (eg textboxes) either. Not sure why the MS code needs to process each 'story' in turn, either. To do the lot (document body, headers, footers and shapes), you could use something like:

    Sub AutoOpen()
    Dim oSection As Section
    Dim oHeadFoot As HeaderFooter
    Dim oShape as Shape
    ActiveDocument.Fields.Update
    For Each oSection In ActiveDocument.Sections
    For Each oHeadFoot In oSection.Footers
    If Not oHeadFoot.LinkToPrevious Then oHeadFoot.Range.Fields.Update
    Next
    For Each oHeadFoot In oSection.Headers
    If Not oHeadFoot.LinkToPrevious Then oHeadFoot.Range.Fields.Update
    Next
    Next 'oSection
    For Each oShape In doc.Shapes
    With oShape.TextFrame
    If .HasText Then
    .TextRange.Fields.Update
    End If
    End With
    Next 'oShape
    End Sub


    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •