D
Doug Claar
I am trying to go through the changes in a document, and only accept the ones
before a certain date. (Someone forgot to accept all the changes before
continuing on, so now the document has all the changes from forever).
I tried this:
Dim output As String
Dim k As Integer
k = 0
For i = 1 To ActiveDocument.Revisions.Count
' For i = 1 To 5
With ActiveDocument.Revisions.Item(i)
If .Date < #5/26/2005# Then
output = output & .Author & " " & .Date & Chr(13)
.Accept
k = k + 1
End If
End With
Next
MsgBox (output)
But after about 30 changes, the Item comes up as "deleted": Not deleted as in
"this text was deleted", deleted as in "this variable has no content"! I
modified my script to not do the Accept, thinking that Accepting one revision
might make others go away, but nothing changed. So I added some code to ignore
deleted ones. Of the 1550 items found by Count, only about 50 were *not*
deleted! And after the script ran, revisions that were before the date were
still showing up in the document.
So I tried:
Dim output As String
Dim k As Integer
k = 0
ActiveDocument.SelectAllEditableRanges
Do While True
Set revTemp = Selection.NextRevision(Wrap:=False)
If Not (revTemp Is Nothing) Then
If .Date < #5/26/2005# Then
output = output & .Author & " " & .Date & Chr(13)
' .Accept
k = k + 1
End If
End If
MsgBox (output)
Loop
But this ran forever! (Well, over 5000 times when I killed it. BTW, is there
any way to interrupt a macro without killing the whole thing in the task
manager? I put in a MsgBox to stop every 500, but that was a pain).
Interestingly, when I capture a macro of going to the next change and
accepting it, the macro uses WordBasic stuff that isn't defined in the VB
help, like:
WordBasic.nextchangeorcomment
Selection.Range.Revisions.AcceptAll
WordBasic.AcceptChangesSelected
Anyone have any thoughts on how to make this work right?
==Doug Claar
before a certain date. (Someone forgot to accept all the changes before
continuing on, so now the document has all the changes from forever).
I tried this:
Dim output As String
Dim k As Integer
k = 0
For i = 1 To ActiveDocument.Revisions.Count
' For i = 1 To 5
With ActiveDocument.Revisions.Item(i)
If .Date < #5/26/2005# Then
output = output & .Author & " " & .Date & Chr(13)
.Accept
k = k + 1
End If
End With
Next
MsgBox (output)
But after about 30 changes, the Item comes up as "deleted": Not deleted as in
"this text was deleted", deleted as in "this variable has no content"! I
modified my script to not do the Accept, thinking that Accepting one revision
might make others go away, but nothing changed. So I added some code to ignore
deleted ones. Of the 1550 items found by Count, only about 50 were *not*
deleted! And after the script ran, revisions that were before the date were
still showing up in the document.
So I tried:
Dim output As String
Dim k As Integer
k = 0
ActiveDocument.SelectAllEditableRanges
Do While True
Set revTemp = Selection.NextRevision(Wrap:=False)
If Not (revTemp Is Nothing) Then
If .Date < #5/26/2005# Then
output = output & .Author & " " & .Date & Chr(13)
' .Accept
k = k + 1
End If
End If
MsgBox (output)
Loop
But this ran forever! (Well, over 5000 times when I killed it. BTW, is there
any way to interrupt a macro without killing the whole thing in the task
manager? I put in a MsgBox to stop every 500, but that was a pain).
Interestingly, when I capture a macro of going to the next change and
accepting it, the macro uses WordBasic stuff that isn't defined in the VB
help, like:
WordBasic.nextchangeorcomment
Selection.Range.Revisions.AcceptAll
WordBasic.AcceptChangesSelected
Anyone have any thoughts on how to make this work right?
==Doug Claar