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
Hi,
Unfortunately, the commands that applied through a VBA code cannot be undone!
So, you have to write a second macro to search for the same sentences and remove their colors!
Regards
Thank you Haytham Amairah .
Are you sure, because Jay said it could be undone indeed by a new macro with the same but slightly changed code?
Please could you tell me how to write a second macro to search for the same sentences and remove their colors? Or, did you mean what Jay suggested?
Sorry, I never used macros before, it is totally new lingo for me, like Escimos language, if you know what I mean, so please have understanding for me.
In my manuscript I have many sentences and paragraphs in different colors (with editing each color tells me something - different colors for different editing categories), so now when all the long sentences turned red, I need them to turn to the previous colors, not to black color, so that I know to which editing category each edited sentence belongs to.
I really appreciate your help, it means a lot to me, so bless you 🙂