Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,470
    Thanks
    30
    Thanked 62 Times in 58 Posts

    Updating Fields (2003 )

    Newly installed Word 2003. I created a document with a half dozen or so ASK fields which are then REFerenced elsewhere, including two of them in the footer.
    I save the document as a template. When I open the template, the ASK fields kick in (I have an AutoOpen running) but (a) only the REF fields in the body of the document are updated (the footer isn't) and ([img]/forums/images/smilies/cool.gif[/img] the ASK field codes themselves vanish from the opened document. Is it natural that the ASK fields vanish once the prompts are answers? Why don't the REF fields in the footer update or, better yet, what am I not doing to get them to update?

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

    Re: Updating Fields (2003 )

    I'm using Word 2002 (XP). ASK fields don't vanish, but REF fields in the header/footer aren't updated automatically when a document is created/opened. See Which fields are updated when you open, repaginate, or print document.

    A trick to force fields to update is to switch to print preview and back:

    ActiveDocument.Fields.Update
    With Application
    .ScreenUpdating = False
    .PrintPreview = True
    .PrintPreview = False
    .ScreenUpdating = True
    End With

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,470
    Thanks
    30
    Thanked 62 Times in 58 Posts

    Re: Updating Fields (2003 )

    I'm getting closer. Where do I put the code you just suggested? Ideally, I want the user to complete the ASK prompts then the REF fields updated automatically without the user having to run a macro.

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

    Re: Updating Fields (2003 )

    If you want the user to be prompted when he/she creates a new document based on the template, put it in the Document_New event procedure (in the ThisDocument module of the template). If you want the user to be prompted when he/she opens an existing document based on the template, put it in the Document_Open event procedure. You can put it in both, if you like.

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,470
    Thanks
    30
    Thanked 62 Times in 58 Posts

    Re: Updating Fields (2003 )

    Maybe answering my own question (correctly or not?)...does that code become the AutoOpen()???

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

    Re: Updating Fields (2003 )

    You could use AutoOpen and/or AutoNew, but I prefer to use the document level event procedures, as indicated in my reply above.

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

    Re: Updating Fields (2003 )

    Hi Kevin,

    A more reliable way to update all fields in a document is:

    Sub UpdateFields()
    Dim pRange as Word.Range
    For each pRange in ActiveDocument.StoryRanges
    Do
    pRange.Fields.Update
    set pRange = pRange.NextStoryRange
    Loop until pRange is nothing
    Next
    End Sub

    Unfortunately, neither doing a print preview nor using ActiveDocument.Fields.Update gets them all.

    If you call the above sub with an AutoNew or Document_New procedure (or the 'open' versions of those), or rename it to whichever of the auto/document procedures you prefer, it should fire off all the ASK fields and update the REF fields.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  8. #8
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Updating Fields (2003 )

    Yet another procedure to update all the fields in a document can be found at Useful Word Procedures

    Alan

  9. #9
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,470
    Thanks
    30
    Thanked 62 Times in 58 Posts

    Re: Updating Fields (2003 )

    That's a GREAT solution and great site. Thanks.

  10. #10
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Updating Fields (2003 )

    Glad it helped, and yes, there's some handy code there.

    Alan

  11. #11
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Updating Fields (2003 )

    I apologize for jumping into a thread on Word 2003, but my access to the Main Index of Woody's Lounge is blocked while I'm a work, and I can only search and reply to posts. In any event, I'm having a problem with updating fields in Word 2000. I have a macro that updates fields and TOCs, but the problem occurs even when I "select all" and press F9. It only started recently. When I update fields, a dialog box appears asking for "History _Rationale". I suspect it's related to some doc property, but I sure can't find it. I've attached a screen shot of the box. This only appears on certain documents, and not all. Some just update properly. One or two give me this dialog box. The box doesn't come from any macro I've written, and there do not appear to be any macros in the files I'm working with that would generate the dialog box. Any ideas on how to get rid of this??

    Thx.

    -Rich Belthoff

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

    Re: Updating Fields (2003 )

    Your screenshot didn't make it. It would be more useful if you could attach (a stripped down copy of) a document that demonstrates the problem. Make sure to remove sensitive information or replace it with dummy data.

  13. #13
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Updating Fields (2003 )

    You may be right that it's associated with a document property, or it could be a document variable embedded in the document(s). The easiest way to check for its appearance within a field code (if the docs aren't too big) is to press Alt+F9 to show all the raw field codes. You may be able to spot the culprit then. You could also attach the document (if <100KB and not confidential) and we could take a closer look.

    Alan

    BTW, your attachment didn't work last time - guess you realize that anyway.

  14. #14
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Updating Fields (2003 )

    Ah ha!! That's it! When I pressed Alt+F9, I found a FILLIN Field. However, I didn't think there were any Fields in the doc cause I ran a search for fields and nothing was found. Does Find not find Fields unless they're displayed?

    BTW, the graphic didn't make it cause I violated the rule of not attaching the file until AFTER I ran "check spelling"! ;-)

    Thanks for the help!

    -Rich Belthoff

  15. #15
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: Updating Fields (2003 )

    Does your code in your response to Kevin also update TOCs? I recorded a macro to update fields, but it wasn't completely updating the TOC (it would only update the page numbers, and not the entire table), so I added some code just for the TOC.

    Thx.

    -Rich Belthoff

Page 1 of 2 12 LastLast

Posting Permissions

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