SOLVED
Home

how can I undo a macro in Word? - SOLVED :)

%3CLINGO-SUB%20id%3D%22lingo-sub-911195%22%20slang%3D%22en-US%22%3ERe%3A%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-911195%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425066%22%20target%3D%22_blank%22%3E%40nata7%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUnfortunately%2C%20the%20commands%20that%20applied%20through%20a%20VBA%20code%20cannot%20be%20undone!%3C%2FP%3E%3CP%3ESo%2C%20you%20have%20to%20write%20a%20second%20macro%20to%20search%20for%20the%20same%20sentences%20and%20remove%20their%20colors!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-911391%22%20slang%3D%22en-US%22%3ERe%3A%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-911391%22%20slang%3D%22en-US%22%3ETo%20clarify%2C%20you%20would%20use%20the%20same%20macro%2C%20except%20replace%20the%20line%3CBR%20%2F%3E%20MySent.Font.Color%20%3D%20wdColorRed%3CBR%20%2F%3Ewith%3CBR%20%2F%3E%20MySent.Font.Color%20%3D%20wdColorAutomatic%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-912318%22%20slang%3D%22en-US%22%3ERe%3A%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-912318%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F216242%22%20target%3D%22_blank%22%3E%40Jay%20Freedman%3C%2FA%3E%20.%20Before%20I%20do%20it%20I%20wanted%20to%20make%20sure%20something%20and%20ask%20you%3A%20when%20I%20do%20that%2C%20will%20the%20color%20than%20turn%20black%20or%20will%20it%20turn%20to%20the%20previous%20color%3F%3C%2FP%3E%3CP%3EIn%20my%20manuscript%20I%20have%20many%20paragraphs%20in%20different%20colors%20(with%20editing%20each%20color%20tells%20me%20something%20-%20different%20colors%20for%20different%20editing%20categories)%2C%20so%20now%20when%20all%20the%20long%20sentences%20turned%20red%2C%20I%20need%20them%20to%20turn%20to%20the%20previous%20colors%2C%20so%20that%20I%20know%20to%20which%20category%20each%20edited%20sentence%20belongs%20to.%3C%2FP%3E%3CP%3EI%20really%20appreciate%20your%20help%2C%20it%20means%20a%20lot%20to%20me%2C%20so%20bless%20you%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-912339%22%20slang%3D%22en-US%22%3ERe%3A%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-912339%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F35679%22%20target%3D%22_blank%22%3E%40Haytham%20Amairah%3C%2FA%3E%20.%3C%2FP%3E%3CP%3EAre%20you%20sure%2C%20because%20Jay%20said%20it%20could%20be%20undone%20indeed%20by%20a%20new%20macro%20with%20the%20same%20but%20slightly%20changed%20code%3F%3C%2FP%3E%3CP%3EPlease%20could%20you%20tell%20me%20how%20to%20write%20a%20second%20macro%20to%20search%20for%20the%20same%20sentences%20and%20remove%20their%20colors%3F%20Or%2C%20did%20you%20mean%20what%20Jay%20suggested%3F%3C%2FP%3E%3CP%3ESorry%2C%20I%20never%20used%20macros%20before%2C%20it%20is%20totally%20new%20lingo%20for%20me%2C%20like%20Escimos%20language%2C%20if%20you%20know%20what%20I%20mean%2C%20so%20please%20have%20understanding%20for%20me.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20my%20manuscript%20I%20have%20many%20sentences%20and%20paragraphs%20in%20different%20colors%20(with%20editing%20each%20color%20tells%20me%20something%20-%20different%20colors%20for%20different%20editing%20categories)%2C%20so%20now%20when%20all%20the%20long%20sentences%20turned%20red%2C%20I%20need%20them%20to%20turn%20to%20the%20previous%20colors%2C%20not%20to%20black%20color%2C%20so%20that%20I%20know%20to%20which%20editing%20category%20each%20edited%20sentence%20belongs%20to.%3C%2FP%3E%3CP%3EI%20really%20appreciate%20your%20help%2C%20it%20means%20a%20lot%20to%20me%2C%20so%20bless%20you%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-912454%22%20slang%3D%22en-US%22%3ERe%3A%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-912454%22%20slang%3D%22en-US%22%3EUnfortunately%2C%20Word%20doesn't%20store%20any%20information%20about%20the%20colors%20those%20sentences%20had%20before%20you%20ran%20the%20first%20macro%2C%20so%20there%20is%20no%20programmable%20way%20to%20restore%20them.%20The%20best%20way%20now%20is%20to%20write%20a%20macro%20that%20locates%20each%20long%20sentence%2C%20and%20displays%20a%20list%20of%20colors%20for%20you%20to%20choose%20the%20one%20you%20want%20to%20apply.%20You%20would%20have%20to%20know%20which%20category%20each%20sentence%20belongs%20to.%20The%20best%20way%20to%20know%20that%20is%20to%20have%20a%20backup%20copy%20of%20the%20document%20from%20before%20the%20original%20macro%20ran%2C%20to%20which%20you%20could%20refer.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-912764%22%20slang%3D%22en-US%22%3ERe%3A%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-912764%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F7352%22%20target%3D%22_blank%22%3E%40Jay%20Freedman%3C%2FA%3E%20but%20I%20don't%20know%20how%20to%20write%20such%20macro%20and%20it%20would%20be%20too%20much%20work%20because%20we%20are%20talking%20about%20almost%201000%20sentences.%3C%2FP%3E%3CP%3EIf%20I%20understood%20your%20suggestion%20correctly%2C%20I%20could%20then%20without%20bothering%20with%20macro%20go%20from%20one%20sentence%20to%20another%20and%20change%20color%2C%20but%20this%20is%20exactly%20what%20I%20want%20to%20avoid%20as%20it%20is%20to%20much%20time-consuming%20and%20tedious%20work.%3C%2FP%3E%3CP%3EAnother%20problem%20is%20that%20I%20had%26nbsp%3B%20the%20option%20to%20track%20changes%20turned%20on%20and%20now%20all%20those%20sentences%20are%20marked%20as%20changed%2C%20although%20nothing%20is%20changed%20in%20them%2C%20so%20the%20editor%20will%20be%20forced%20to%20look%20into%20them%20although%20nothing%20is%20there%20to%20look.%20A%20horrible%20situation%20as%20it%20requires%20too%20much%20extra%20work%2C%20which%20is%20why%20I%20am%20trying%20to%20find%20a%20solution.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESince%20I%20had%20%22Track%20Changes%22%20on%2C%20is%20there%20a%20way%20to%20simply%20discard%20the%20changes%20made%20that%20hour%20or%20day%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-912856%22%20slang%3D%22en-US%22%3ERe%3A%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-912856%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425066%22%20target%3D%22_blank%22%3E%40nata7%3C%2FA%3E%26nbsp%3BI%20don't%20think%20Word%20will%20help%20you%20here.%20You%20can%20accept%20or%20reject%20%3CSTRONG%3Eall%3C%2FSTRONG%3E%20of%20the%20changes%20in%20the%20document%2C%20or%20you%20can%20accept%20or%20reject%20them%20one%20at%20a%20time%20and%20skip%20over%20the%20ones%20you%20want%20to%20keep%20tracking.%20However%2C%20there's%20no%20simple%20way%20to%20reject%20only%20the%20changes%20made%20during%20a%20specific%20time%20period.%20Again%2C%20that%20could%20be%20done%20with%20a%20macro%2C%20but%20you%20would%20need%20specific%20knowledge%20about%20VBA%20and%20Word's%20objects.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20thing%20that%20may%20be%20helpful%3A%20If%20tracking%20of%20formatting%20changes%20is%20enabled%20(which%20I%20believe%20it%20is%20by%20default)%2C%20you%20can%20use%20the%20Next%20button%20on%20the%20Review%20ribbon%20(in%20the%20Changes%20group)%20to%20jump%20from%20one%20tracked%20change%20to%20the%20next%20one%2C%20and%20when%20you%20come%20to%20a%20red-colored%20long%20sentence%2C%20just%20click%20the%20Reject%20button%20--%20that%20will%20remove%20the%20red%20and%20leave%20the%20previous%20color.%20Yes%2C%20it%20will%20be%20tedious%2C%20but%20less%20so%20than%20doing%20all%20the%20recoloring%20manually.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-912890%22%20slang%3D%22en-US%22%3ERe%3A%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-912890%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F216242%22%20target%3D%22_blank%22%3E%40Jay%20Freedman%3C%2FA%3E%20.%3C%2FP%3E%3CP%3EI%20have%20over%203000%20changes%20in%20the%20Reviewing%20Pane.%20I%20am%20guessing%20almost%201000%20of%20them%20are%20the%20problematic%20changes%20of%20long%20sentences%20to%20red%20color.%20So%2C%20it%20is%20really%20too%20much%20work%20also%20to%20look%20through%20all%20the%203000%2B%20changes.%3C%2FP%3E%3CP%3EIs%20it%20possible%20to%20filter%20all%20the%20tracked%20changes%20according%20to%20date%3F%20This%20way%20at%20least%20I%20wouldnt%20have%20to%20go%20through%20all%20changes%20since%20I%20would%20have%20all%20the%20problematic%20ones%20listed%20one%20after%20the%20other.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-913277%22%20slang%3D%22en-US%22%3ERe%3A%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-913277%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425066%22%20target%3D%22_blank%22%3E%40nata7%3C%2FA%3E%26nbsp%3BAs%20I%20mentioned%20briefly%20before%2C%20a%20macro%20can%20examine%20the%20date%20on%20which%20a%20tracked%20change%20was%20made%2C%20and%20decide%20whether%20to%20reject%20that%20change.%20The%20following%20macro%20asks%20you%20to%20enter%20the%20date%20that%20the%20changes%20were%20made.%20It%20then%20looks%20at%20each%20tracked%20change%20(all%203000%20of%20them).%20If%20the%20change's%20date%20matches%20the%20date%20you%20entered%2C%20and%20if%20the%20font%20color%20of%20that%20change%20is%20red%2C%20then%20the%20macro%20rejects%20that%20change.%20Otherwise%20the%20change%20is%20ignored.%20The%20macro%20counts%20the%20number%20of%20changes%20it%20rejected%2C%20and%20displays%20the%20number%20in%20the%20status%20bar%20at%20the%20bottom%20of%20the%20Word%20window%20and%20in%20a%20message%20box%20when%20the%20macro%20finishes.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESub%20RejectTimedRevision()%3CBR%20%2F%3EDim%20objRev%20As%20Revision%3CBR%20%2F%3EDim%20objDate%20As%20Date%3CBR%20%2F%3EDim%20strDate%20As%20String%3CBR%20%2F%3EDim%20lngCount%20As%20Long%3CBR%20%2F%3E%3CBR%20%2F%3EGetDate%3A%3CBR%20%2F%3EstrDate%20%3D%20InputBox(prompt%3A%3D%22Enter%20date%20of%20changes%3A%22%2C%20_%3CBR%20%2F%3ETitle%3A%3D%22Reject%20Changes%20from%20Specified%20Date%22)%3CBR%20%2F%3EIf%20strDate%20%3D%20%22%22%20Then%20Exit%20Sub%3CBR%20%2F%3EIf%20IsDate(strDate)%20Then%3CBR%20%2F%3EobjDate%20%3D%20CDate(strDate)%3CBR%20%2F%3EElse%3CBR%20%2F%3EMsgBox%20strDate%20%26amp%3B%20%22%20is%20not%20a%20valid%20date.%20Try%20again.%22%3CBR%20%2F%3EGoTo%20GetDate%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20Each%20objRev%20In%20ActiveDocument.Revisions%3CBR%20%2F%3EIf%20InStr(objRev.Date%2C%20objDate)%20And%20_%3CBR%20%2F%3E(objRev.Range.Font.ColorIndex%20%3D%20wdRed)%20Then%3CBR%20%2F%3EobjRev.Reject%3CBR%20%2F%3ElngCount%20%3D%20lngCount%20%2B%201%3CBR%20%2F%3EStatusBar%20%3D%20CStr(lngCount)%20%26amp%3B%20%22%20revisions%20rejected%22%3CBR%20%2F%3EEnd%20If%3CBR%20%2F%3ENext%20objRev%3CBR%20%2F%3E%3CBR%20%2F%3EMsgBox%20CStr(lngCount)%20%26amp%3B%20%22%20revisions%20rejected%22%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-914185%22%20slang%3D%22en-US%22%3ERe%3A%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-914185%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F216242%22%20target%3D%22_blank%22%3E%40Jay%20Freedman%3C%2FA%3E%20%2C%20you%20are%20so%20kind%2C%20I%20really%20appreciate%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20created%20and%20run%20your%20macro.%20I%20entered%20the%20date%20and%20in%20the%20end%20the%20message%20popped%20up%3A%20%220%20revisions%20were%20rejected%22%20-%20How%20come%3F%20Could%20it%20be%20possible%20that%20there%20is%20some%20error%20in%20the%20macro%20or%20in%20something%20else%20-%20maybe%20in%20the%20date%20form%3F%20I%20entered%20the%20date%2010%2F12%2F2019%20-%20because%20this%20is%20how%20dates%20are%20displayed%20in%20the%20Review%20pane%20of%20my%20Word%20document%2C%20but%20overhere%20we%20write%20dates%2012.10.2019.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%2C%20could%20the%20problem%26nbsp%3Bbe%20that%20I%20did%20it%20in%20a%20copy%20of%20that%20document%20(to%20test%20it%20if%20it%20works)%3F%20Since%20my%20first%20experiment%20with%20macros%20turned%20very%20bad%2C%20I%20am%20now%20very%20cautious%20of%20using%20it%2C%20so%20I%20made%20a%20copy%20of%20my%20manuscript%20and%20run%20your%20macro%20there.%20Must%20I%20do%20it%20directly%20in%20the%20original%20document%3F%20In%20the%20copy%20are%20all%20the%20changes%20recorded%20in%20the%20Review%20pane%20and%20could%20be%20accepted%20or%20rejected%2C%20but%20those%20changes%20were%20not%20actually%20made%20in%20that%20copy%20(they%20were%20made%20in%20the%20original%20document).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-914390%22%20slang%3D%22en-US%22%3ERe%3A%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-914390%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425066%22%20target%3D%22_blank%22%3E%40nata7%3C%2FA%3E%26nbsp%3BVBA%20is%20a%20bit%20unpredictable%20about%20the%20way%20it%20interprets%20dates%20entered%20as%20strings.%20It%20depends%20mostly%20on%20your%20Windows%20settings%2C%20particularly%20the%20Short%20Date%20format.%20I%20suspect%20that%20when%20you%20entered%2010%2F12%2F2013%20(as%20month%2Fday%2Fyear%2C%20which%20is%20the%20default%20for%20US%20English)%2C%20the%20program%20interpreted%20it%20in%20day%2Fmonth%2Fyear%20format%20as%2010%20December%202019.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETry%20running%20the%20macro%20again%20and%20enter%20the%20date%20as%2012%2F10%2F2019%20to%20see%20whether%20it%20works.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-915973%22%20slang%3D%22en-US%22%3ERe%3A%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-915973%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F216242%22%20target%3D%22_blank%22%3E%40Jay%20Freedman%3C%2FA%3E%20%2C%20you%20are%20my%20saviour%20here!%20You%20were%20right%2C%20your%20macro%20worked%20with%20the%20date%20form%20you%20suggested.%3C%2FP%3E%3CP%3EIf%20someone%20is%20reading%20this%20who%20is%20also%20in%20similar%20predicament%2C%20let%20there%20be%20no%20confusion%2C%20this%20solution%20works%20but%20only%20if%20you%20had%20%22Track%20Changes%22%20on.%3C%2FP%3E%3CP%3EBless%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-910922%22%20slang%3D%22en-US%22%3Ehow%20can%20I%20undo%20a%20macro%20in%20Word%3F%20-%20SOLVED%20%3A)%3C%2Fimg%3E%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-910922%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EHi%2C%20how%20can%20I%20undo%20a%20macro%20in%20Word%3F%20I%20added%20a%20code%20to%20mark%20long%20sentences%20and%20I%20run%20it.This%20is%20the%20code%3A%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CDIV%20class%3D%22crayon-pre%22%3E%3CDIV%20class%3D%22crayon-line%22%3E%3CSPAN%20class%3D%22crayon-t%22%3ESub%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-e%22%3EMark_Long%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-sy%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-sy%22%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%20crayon-striped-line%22%3E%3CSPAN%20class%3D%22crayon-h%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-r%22%3EDim%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-e%22%3EiMyCount%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-r%22%3EAs%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-e%22%3EInteger%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%22%3E%3CSPAN%20class%3D%22crayon-e%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-r%22%3EDim%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-e%22%3EiWords%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-r%22%3EAs%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-e%22%3EInteger%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%20crayon-striped-line%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%22%3E%3CSPAN%20class%3D%22crayon-e%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3EIf%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3ENot%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EActiveDocument%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-sy%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3ESaved%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3EThen%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%20crayon-striped-line%22%3E%3CSPAN%20class%3D%22crayon-e%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EActiveDocument%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-sy%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3ESave%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%22%3E%3CSPAN%20class%3D%22crayon-e%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-st%22%3EEnd%3C%2FSPAN%3E%20If%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%20crayon-striped-line%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%22%3E%3CSPAN%20class%3D%22crayon-h%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-c%22%3E'Reset%20counter%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%20crayon-striped-line%22%3E%3CSPAN%20class%3D%22crayon-h%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EiMyCount%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-o%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-cn%22%3E0%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%20crayon-striped-line%22%3E%3CSPAN%20class%3D%22crayon-h%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-c%22%3E'Set%20number%20of%20words%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%22%3E%3CSPAN%20class%3D%22crayon-h%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EiWords%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-o%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-cn%22%3E50%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-c%22%3E'%20%26lt%3B%3D%3D%3D%3D%20change%20as%20required%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%20crayon-striped-line%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%22%3E%3CSPAN%20class%3D%22crayon-h%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3EFor%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3EEach%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3EMySent%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3EIn%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EActiveDocument%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-sy%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3ESentences%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%20crayon-striped-line%22%3E%3CSPAN%20class%3D%22crayon-e%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3EIf%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EMySent%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-sy%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EWords%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-sy%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3ECount%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-o%22%3E%26gt%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-e%22%3EiWords%20%3C%2FSPAN%3EThen%20%3CSPAN%20class%3D%22crayon-c%22%3E'%20%26lt%3B%3D%3D%3D%3D%20play%20with%20to%20look%20at%20sentences%20of%20varying%20length%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%22%3E%3CSPAN%20class%3D%22crayon-h%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EMySent%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-sy%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EFont%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-sy%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EColor%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-o%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-e%22%3EwdColorRed%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%20crayon-striped-line%22%3E%3CSPAN%20class%3D%22crayon-e%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EiMyCount%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-o%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-v%22%3EiMyCount%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-o%22%3E%2B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-cn%22%3E1%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%22%3E%3CSPAN%20class%3D%22crayon-h%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-st%22%3EEnd%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-e%22%3EIf%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%20crayon-striped-line%22%3E%3CSPAN%20class%3D%22crayon-e%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-r%22%3ENext%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%22%3E%3CSPAN%20class%3D%22crayon-h%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-e%22%3EMsgBox%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EiMyCount%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-o%22%3E%26amp%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-s%22%3E%22%20sentences%20longer%20than%20%22%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-o%22%3E%26amp%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-sy%22%3E_%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%20crayon-striped-line%22%3E%3CSPAN%20class%3D%22crayon-h%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-v%22%3EiWords%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-o%22%3E%26amp%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-s%22%3E%22%20words.%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%20class%3D%22crayon-line%22%3E%3CSPAN%20class%3D%22crayon-st%22%3EEnd%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22crayon-t%22%3ESub%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ENow%20all%20my%20long%20sentences%20(cca.%201000%20of%20them%20-%20it%20is%20a%20manuscript)%20are%20in%20red%20color%20but%20I%20want%20to%20undo%20it%20so%20that%20they%20are%20no%20longer%20in%20red%20-%20how%20can%20I%20do%20it%3F%20My%20document%20is%20in%20more%20colors%2C%20so%20there%20is%20no%20use%20of%20simply%20changing%20font%20color.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAlso%2C%20I%20don't%20know%20why%2C%20maybe%20some%20bug%20or%20error%2C%20the%20Word%20document%20closed%20and%20reopened%20itself%2C%20so%20no%20use%20of%20the%20%22undo%22%20action%20in%20Word.%20I%20need%20to%20undo%20the%20macro.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20already%20deleted%20the%20macro%2C%20so%20it%20is%20not%20there%20anymore%2C%20but%20how%20do%20I%20undo%20what%20that%20macro%20did%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EThank%20you%20in%20advance!%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EUPDATE%3A%20solution%20was%20provided%20by%20generous%20and%20great%20Jay%20(marked%20as%20best%20response).%20This%20solution%20is%20for%20you%20too%20if%20you%20had%20%22Track%20Changes%22%20on%20because%20the%20new%20macro%20automatically%20rejects%20all%20those%20changes%20on%20that%20date.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
nata7
Occasional Contributor

Hi, how can I undo a macro in Word? I added a code to mark long sentences and I run it.This is the code:

Sub Mark_Long()
    Dim iMyCount As Integer
    Dim iWords As Integer
 
    If Not ActiveDocument.Saved Then
        ActiveDocument.Save
    End If
 
    'Reset counter
    iMyCount = 0
 
    'Set number of words
    iWords = 50 ' <==== change as required
 
    For Each MySent In ActiveDocument.Sentences
        If MySent.Words.Count > iWords Then ' <==== play with to look at sentences of varying length
            MySent.Font.Color = wdColorRed
            iMyCount = iMyCount + 1
        End If
    Next
    MsgBox iMyCount & " sentences longer than " & _
      iWords & " words."
End Sub

 

Now all my long sentences (cca. 1000 of them - it is a manuscript) are in red color but I want to undo it so that they are no longer in red - how can I do it? My document is in more colors, so there is no use of simply changing font color.

Also, I don't know why, maybe some bug or error, the Word document closed and reopened itself, so no use of the "undo" action in Word. I need to undo the macro.

I already deleted the macro, so it is not there anymore, but how do I undo what that macro did?

Thank you in advance!

 

UPDATE: solution was provided by generous and great Jay (marked as best response). There are actually two solutions. The first and easy one was  to use a new macro with the same code as old macro but just with a change of line about color. I didn't want the color to change to automatic color, so I needed another solution. That solution is for you too if you had "Track Changes" on because the new macro automatically rejects all those changes on that date.

12 Replies

@nata7

 

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

To clarify, you would use the same macro, except replace the line
MySent.Font.Color = wdColorRed
with
MySent.Font.Color = wdColorAutomatic

Thank you@Jay Freedman . Before I do it I wanted to make sure something and ask you: when I do that, will the color than turn black or will it turn to the previous color?

In my manuscript I have many 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, so that I know to which category each edited sentence belongs to.

I really appreciate your help, it means a lot to me, so bless you :)

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 :)

Unfortunately, Word doesn't store any information about the colors those sentences had before you ran the first macro, so there is no programmable way to restore them. The best way now is to write a macro that locates each long sentence, and displays a list of colors for you to choose the one you want to apply. You would have to know which category each sentence belongs to. The best way to know that is to have a backup copy of the document from before the original macro ran, to which you could refer.

Thank you@Jay 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?

@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.

Thank you@Jay 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.

Solution

@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 you@Jay Freedman , you are so kind, I really appreciate it.

 

I created and run your macro. I entered the date and in the end the message popped up: "0 revisions were rejected" - How come? Could it be possible that there is some error in the macro or in something else - maybe in the date form? I entered the date 10/12/2019 - because this is how dates are displayed in the Review pane of my Word document, but overhere we write dates 12.10.2019.

 

Or, could the problem be that I did it in a copy of that document (to test it if it works)? Since my first experiment with macros turned very bad, I am now very cautious of using it, so I made a copy of my manuscript and run your macro there. Must I do it directly in the original document? In the copy are all the changes recorded in the Review pane and could be accepted or rejected, but those changes were not actually made in that copy (they were made in the original document).

@nata7 VBA is a bit unpredictable about the way it interprets dates entered as strings. It depends mostly on your Windows settings, particularly the Short Date format. I suspect that when you entered 10/12/2013 (as month/day/year, which is the default for US English), the program interpreted it in day/month/year format as 10 December 2019.

 

Try running the macro again and enter the date as 12/10/2019 to see whether it works.

Thank you@Jay Freedman , you are my saviour here! You were right, your macro worked with the date form you suggested.

If someone is reading this who is also in similar predicament, let there be no confusion, this solution works but only if you had "Track Changes" on.

Bless you!

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
35 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies