none
Track changes in header/footer don't count as revisions ? RRS feed

  • Question

  • Hi

     

    I made a script to accept all changes in word documents with the partial following code :

       If mydoc.Revisions.Count >= 1 Then
            mydoc.Revisions.AcceptAll
        Else
            mydoc.Close wdDoNotSaveChanges
            Exit Sub
        End If

     

    but in this documents :

    https://docs.google.com/leaf?id=0B89kpVmq9Yr3M2UwZjNiOTktMTBmNy00OWE0LWIxMjQtNTlmMWU3MTExZWY5&hl=en_GB

    count show 0 yet there is plenty formatting left.

    If i record a macro to accept thoses changes, macro is blank, so can anyone tell me what is going on  because when i go into the document and click acceptall changes they are removed.

     

    Thanks in advance

    Tuesday, August 9, 2011 12:03 PM

Answers

  • Hi Jerome,

    It's most likely because the insert point is still in the main content area of the document. If you're going to use that technique then you need a Range.Select command.

    If you use a range command instead, I know that works.

    Dim rng as Word.Range

    Dim doc as Word.document

    Set doc = Word.ActiveDocument

    rng = doc.Sections(1).Headers(Word.

    WdHeaderFooterIndex.wdHeaderFooterPrimary).Range

    rng.Revisions.AcceptAll


    Kind Regards, Rich ... http://greatcirclelearning.com
    • Marked as answer by Jerome Bana Tuesday, August 9, 2011 5:35 PM
    Tuesday, August 9, 2011 1:57 PM

All replies

  • The revision count only shows revisions in the main content story. AFAIK you'll have to loop thru the various document stories and see if there are revisions in those areas as well.

    Hope this helps


    Kind Regards, Rich ... http://greatcirclelearning.com
    Tuesday, August 9, 2011 12:56 PM
  • ok understood that so i added this to my code ;


         ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
         If Selection.Range.Revisions.Count >= 1 Then
            Selection.Range.Revisions.AcceptAll
         End If
         ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
         If Selection.Range.Revisions.Count >= 1 Then
            Selection.Range.Revisions.AcceptAll
         End If

     

    does actually show me a non nil revision count for both but still doesn't accept them :( am i missing something ?

    Tuesday, August 9, 2011 1:13 PM
  • Hi Jerome,

    It's most likely because the insert point is still in the main content area of the document. If you're going to use that technique then you need a Range.Select command.

    If you use a range command instead, I know that works.

    Dim rng as Word.Range

    Dim doc as Word.document

    Set doc = Word.ActiveDocument

    rng = doc.Sections(1).Headers(Word.

    WdHeaderFooterIndex.wdHeaderFooterPrimary).Range

    rng.Revisions.AcceptAll


    Kind Regards, Rich ... http://greatcirclelearning.com
    • Marked as answer by Jerome Bana Tuesday, August 9, 2011 5:35 PM
    Tuesday, August 9, 2011 1:57 PM
  • will try this, i actually ended with trying this code :

    Dim oRange As Word.Range
    Dim Fld As Field

    With ActiveDocument
    ' Loop through all range objects and accept tracked changes on fields
    For Each oRange In .StoryRanges
    Do
    For Each Fld In oRange.Fields
    Fld.Select
    Selection.Range.Revisions.AcceptAll
    Next
    Set oRange = oRange.NextStoryRange
    Loop Until oRange Is Nothing
    Next
    End With

    It did accept 2 of 9 revisions, no idea why not the others.

     

    just tried your code

    oRange = mydoc.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range
    oRange.Revisions.AcceptAll

    but i got an error 91 : Object variable or With block variable not set

    kinda clueless now :(

     

    Tuesday, August 9, 2011 2:05 PM
  • Put a Set command in front of oRange. I clipped my sample from VB.Net, which doesn't use them.

     


    Kind Regards, Rich ... http://greatcirclelearning.com
    Tuesday, August 9, 2011 2:12 PM
  • Thanks for the help it worked.

    i discovered aswell for

      ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    If Selection.Range.Revisions.Count >= 1 Then
    Selection.Range.Revisions.AcceptAll
    End If

    if after i display (in step by step) the header I select all the text (ctrl+a or F8 3 timeS) the acceptall seems to work, weird thing is selection.range.revisions.count do give me the right count for header revisions without doing this sellect all.

    Tuesday, August 9, 2011 5:37 PM