Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Mount Prospect, Illinois
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Updating Fields 'Word cannot undo...' (97-2003)

    If you use VBA to update fields in certain story ranges, Word displays a message box saying "Word cannot undo this action. Do you want to continue?"
    Is there any way to avoid those dialogs appearing, or barring that, detect that they've popped and SendKeys them to oblivion?
    Right now, I skip some of the story ranges when I do update on all fields, but that could lead to inconsistent cross references.

    Example Code (note, you must have a footnote, and a field of any sort in the footnote):

    activedocument.StoryRanges(wdFootnotesStory).Field s.Update

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Updating Fields 'Word cannot undo...' (97-2003

    Hi Joel:
    Does the macro in <post#=294288>post 294288</post#> help?

  3. #3
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Mount Prospect, Illinois
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Updating Fields 'Word cannot undo...' (97-2003)

    <P ID="edit" class=small>(Edited by jscher2000 on 09-Jul-04 13:43. Longer lines broken to preserve Lounge formatting and protect the interest of e-mail digest recipients!)</P>Well, found one way: Update one at a time for those ranges that complain:
    <pre> Dim r As Range
    Dim toc As TableOfContents
    Dim fld As Field

    ' First, explicitly update the TOCs, so that there's no prompt from them
    For Each toc In ActiveDocument.TablesOfContents
    toc.Update
    Next toc
    For Each r In ActiveDocument.StoryRanges
    ' Some story ranges display dialogs when updating all fields at once.
    ' Therefore, update them singly
    If r.StoryType = wdEndnotesStory Or r.StoryType = wdFootnotesStory Or _
    r.StoryType = wdCommentsStory Then
    For Each fld In r.Fields
    fld.Update
    Next fld
    Else ' for everything else, a quickie update is quiet
    If r.Fields.Count > 0 Then r.Fields.Update
    End If
    Next r
    </pre>


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

    Re: Updating Fields 'Word cannot undo...' (97-2003)

    Hi,

    Suppressing the warnings may be as simple as executing 'Application.DisplayAlerts = wdAlertsNone', and remember to reset this to 'Application.DisplayAlerts = wdAlertsAll' when you're done.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    2 Star Lounger
    Join Date
    Jan 2004
    Location
    Mount Prospect, Illinois
    Posts
    142
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Updating Fields 'Word cannot undo...' (97-2003)

    Thanks to all -- that previous post seems to cover every possible outcome. I did make a couple changes to it,
    1) turning off DisplayAlerts for all story ranges, and then not bothering to check what kind it is, because not just Comments cause the problem
    2) Updating TOCs prior to everything else, because that eliminates the "rebuild/just pg num" queries when updating fields

Posting Permissions

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