Forum Discussion
how can I undo a macro in Word? - SOLVED :)
- Oct 14, 2019
nata7 As I mentioned briefly before, a macro can examine the date on which a tracked change was made, and decide whether to reject that change. The following macro asks you to enter the date that the changes were made. It then looks at each tracked change (all 3000 of them). If the change's date matches the date you entered, and if the font color of that change is red, then the macro rejects that change. Otherwise the change is ignored. The macro counts the number of changes it rejected, and displays the number in the status bar at the bottom of the Word window and in a message box when the macro finishes.
Sub RejectTimedRevision()
Dim objRev As Revision
Dim objDate As Date
Dim strDate As String
Dim lngCount As Long
GetDate:
strDate = InputBox(prompt:="Enter date of changes:", _
Title:="Reject Changes from Specified Date")
If strDate = "" Then Exit Sub
If IsDate(strDate) Then
objDate = CDate(strDate)
Else
MsgBox strDate & " is not a valid date. Try again."
GoTo GetDate
End If
For Each objRev In ActiveDocument.Revisions
If InStr(objRev.Date, objDate) And _
(objRev.Range.Font.ColorIndex = wdRed) Then
objRev.Reject
lngCount = lngCount + 1
StatusBar = CStr(lngCount) & " revisions rejected"
End If
Next objRev
MsgBox CStr(lngCount) & " revisions rejected"
End Sub
Thank youJay Freedman but I don't know how to write such macro and it would be too much work because we are talking about almost 1000 sentences.
If I understood your suggestion correctly, I could then without bothering with macro go from one sentence to another and change color, but this is exactly what I want to avoid as it is to much time-consuming and tedious work.
Another problem is that I had the option to track changes turned on and now all those sentences are marked as changed, although nothing is changed in them, so the editor will be forced to look into them although nothing is there to look. A horrible situation as it requires too much extra work, which is why I am trying to find a solution.
Since I had "Track Changes" on, is there a way to simply discard the changes made that hour or day?
- Jay FreedmanOct 14, 2019MVP
nata7 I don't think Word will help you here. You can accept or reject all of the changes in the document, or you can accept or reject them one at a time and skip over the ones you want to keep tracking. However, there's no simple way to reject only the changes made during a specific time period. Again, that could be done with a macro, but you would need specific knowledge about VBA and Word's objects.
One thing that may be helpful: If tracking of formatting changes is enabled (which I believe it is by default), you can use the Next button on the Review ribbon (in the Changes group) to jump from one tracked change to the next one, and when you come to a red-colored long sentence, just click the Reject button -- that will remove the red and leave the previous color. Yes, it will be tedious, but less so than doing all the recoloring manually.
- nata7Oct 14, 2019Copper Contributor
Thank youJay Freedman .
I have over 3000 changes in the Reviewing Pane. I am guessing almost 1000 of them are the problematic changes of long sentences to red color. So, it is really too much work also to look through all the 3000+ changes.
Is it possible to filter all the tracked changes according to date? This way at least I wouldnt have to go through all changes since I would have all the problematic ones listed one after the other.
- Jay FreedmanOct 14, 2019MVP
nata7 As I mentioned briefly before, a macro can examine the date on which a tracked change was made, and decide whether to reject that change. The following macro asks you to enter the date that the changes were made. It then looks at each tracked change (all 3000 of them). If the change's date matches the date you entered, and if the font color of that change is red, then the macro rejects that change. Otherwise the change is ignored. The macro counts the number of changes it rejected, and displays the number in the status bar at the bottom of the Word window and in a message box when the macro finishes.
Sub RejectTimedRevision()
Dim objRev As Revision
Dim objDate As Date
Dim strDate As String
Dim lngCount As Long
GetDate:
strDate = InputBox(prompt:="Enter date of changes:", _
Title:="Reject Changes from Specified Date")
If strDate = "" Then Exit Sub
If IsDate(strDate) Then
objDate = CDate(strDate)
Else
MsgBox strDate & " is not a valid date. Try again."
GoTo GetDate
End If
For Each objRev In ActiveDocument.Revisions
If InStr(objRev.Date, objDate) And _
(objRev.Range.Font.ColorIndex = wdRed) Then
objRev.Reject
lngCount = lngCount + 1
StatusBar = CStr(lngCount) & " revisions rejected"
End If
Next objRev
MsgBox CStr(lngCount) & " revisions rejected"
End Sub