• Updating Fields ‘Word cannot undo…’ (97-2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Updating Fields ‘Word cannot undo…’ (97-2003)

    Author
    Topic
    #407138

    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).Fields.Update

    Viewing 5 reply threads
    Author
    Replies
    • #849411

      Hi Joel:
      Does the macro in post 294288 help?

    • #849412

      Hi Joel:
      Does the macro in post 294288 help?

    • #849340

      (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!)

      Well, found one way: Update one at a time for those ranges that complain:

          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
      
      • #849576

        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
        [Fmr MS MVP - Word]

      • #849577

        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
        [Fmr MS MVP - Word]

    • #849341

      (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!)

      Well, found one way: Update one at a time for those ranges that complain:

          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
      
    • #849635

      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

    • #849636

      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

    Viewing 5 reply threads
    Reply To: Updating Fields ‘Word cannot undo…’ (97-2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: