|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Hi, I have created some macros that do various "find/replace" actions. But I notice that the macros do not work when "track changes" is turned on. Is there a way to run these kinds of macros with track changes turned on?
Thanks Amy
|
|
Hi Amy,
It seems to work fine in my environment (Windows XP and Word 2003)
ActiveDocument.TrackRevisions = True With Selection.Find .Text = "test" With .Replacement .Text = "Replaced" End With .Execute Replace:=wdReplaceAll End With
HTH, Dave
"Amy" <Amy[ at ]discussions.microsoft.com> wrote in message news:75F75A97-ACC9-4D81-B4F3-B1EF4720D490[ at ]microsoft.com...
[Quoted Text] > Hi, I have created some macros that do various "find/replace" actions. But > I > notice that the macros do not work when "track changes" is turned on. Is > there a way to run these kinds of macros with track changes turned on? > > Thanks > Amy
|
|
The idea is to find out whether Tracking is on, and save that result in a variable. Then turn off Tracking, do your work, and finally restore the original state. Here's code:
Dim WasTrackingOn As Boolean WasTrackingOn = ActiveDocument.TrackRevisions ActiveDocument.TrackRevisions = False
' do your find/replace operations here
ActiveDocument.TrackRevisions = WasTrackingOn
Of course, if you use a variable of Document type to work on some other document, substitute that variable for ActiveDocument.
-- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
Amy wrote:
[Quoted Text] > Hi, I have created some macros that do various "find/replace" > actions. But I notice that the macros do not work when "track > changes" is turned on. Is there a way to run these kinds of macros > with track changes turned on? > > Thanks > Amy
|
|
Hi Amy,
not really, IMHO. Unless you *must* track changes, make sure, track track changes is turned of. Otherwise, you'd have to check whether the range of the found text has a revisions count > 0.
Still there is the danger of endless loops.
-- Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003 "red.sys" & Chr$(64) & "t-online.de"
|
|
"Amy" <Amy[ at ]discussions.microsoft.com> wrote in message news:75F75A97-ACC9-4D81-B4F3-B1EF4720D490[ at ]microsoft.com...
[Quoted Text] > Hi, I have created some macros that do various "find/replace" actions. But > I > notice that the macros do not work when "track changes" is turned on. Is > there a way to run these kinds of macros with track changes turned on? > > Thanks > Amy
The problem is probably that the macros are working, but the conditions are not as you would expect them to be,
Suppose you originally had "this whole phrase" in the document, and then decided to delete "whole". So you now have "this phrase", and you do a search on that string. The Find will *not* find it, because "whole" is still there but marked with a deletion.
Furthermore, if deleted text is hidden, the Find won't find "this whole phrase" either, but it will find it if the deleted text is marked with strikethrough or some other visible formatting.
-- Regards Jonathan West - Word MVP www.intelligentdocuments.co.uk Please reply to the newsgroup Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
|
|
|