Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    file name field update automatically (Word 2000)

    Hi there

    How do I create a file name field that updated automatically when the file is saved with a new name?
    I have tried the field code Filename a but it does not update when the file is saved with a new name.

    Kind regards

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

    Re: file name field update automatically (Word 2000)

    Hi Lynden,

    The FILENAME field is one that doesn't automatically update if it's in the body of the document, but will do so in a header or footer when you close/re-open the file or do a Print Preview. When the field is in the body of the document, you need to manually update the field, update it via a macro, or print the file - you can update the field when it's in the header or footer the same way too.

    Cheers
    PS: The FILENAME field supports a p switch but not the a switch.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  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: file name field update automatically (Word 2000)

    If you want to update all the fields in the document after a Save As, you can write your own Save As macro to replace the Save As command. It's not so bad for one computer, but distributing something like that to multiple users might be more trouble than it's worth. Want to try it?

    <pre>Sub FileSaveAs()
    ' Save As dialog + field updates
    With Dialogs(wdDialogFileSaveAs)
    If .Show = -1 Then 'user saved
    'Update fields (does not reach unique headers
    ' and footers after section 1)
    Dim rng As Range
    For Each rng In ActiveDocument.StoryRanges
    rng.Fields.Update
    Next rng
    If Not (rng Is Nothing) Then Set rng = Nothing
    End If
    End With
    End Sub</pre>

    Hope this helps.

  4. #4
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: file name field update automatically (Word 2000)

    Thanks for the additional information. Have placed the field in the footer, and the users are happy with it now.
    Regards

  5. #5
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: file name field update automatically (Word 2000)

    Have tried it for myself and it works - thanks.
    The users have requested that the field is placed in the footer, so let's hope that works (or an F9!!!)
    Kind regards

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

    Re: file name field update automatically (Word 2000)

    Hi Lynden,

    To automate the update, you could insert a macro like the following:

    Sub FileSaveAs()
    With Application.Dialogs(wdDialogFileSaveAs)
    .Display
    .Execute
    End With
    With ActiveDocument
    .PrintPreview
    .ClosePrintPreview
    .Save
    End With
    End Sub

    This forces the filename field in a header or footer, plus various other fields, to update immediately the document is saved with a new name (using File|Save As), then re-saves the document in the updated state.

    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
  •