Can a macro address tracked changes?
Can a macro address tracked changes?
I'm working on a long document containing many tracked changes. I'd like to accept the 95 percent of the changes that relate to formatting, and keep the rest. Could a macro parse tracked changes and distinguish between the different types?
Thanks
Charles
Thanks
Charles
Re: Can a macro address tracked changes?
In principle yes. The Nisus macro language has the ability to access tracked changes. The tracked change object has a .isTextContentChanged property (among others), so it seems it would be possible to distinguish the ones you are looking for.
philip
Re: Can a macro address tracked changes?
This macro would seem to do the trick (Test it on a copy, please!).
Code: Select all
$doc = Document.active
$changes = $doc.allTrackedChanges
foreach $change in $changes
if ! $change.isTextContentChanged
$change.accept
end
end
philip
Re: Can a macro address tracked changes?
Philip, you are a genius. That works perfectly, except for changes to the language. Is there a corresponding property for this? I tried "isTextLanguageChanged" and "isLanguageChanged", but neither of these works.This macro would seem to do the trick
Background: I'm exchanging an RTF document with several Word users. Change tracking and commenting generally works very well. However, the document returned by one user has hundreds of marked changes relating to formatting. Perhaps she is the only one to have "track formatting changes" turned on in Word, but it's difficult to control how other people work, so with this macro it's easier to strip them out. I don't think any of these formatting changes are "real" -- in other words, I don't think my colleague has made them deliberately. If anyone can shed light on this I'd be very pleased.
Taking a wider view, is there a reference somewhere for all these macro properties? I'm extremely grateful for the help, but I could probably have figured this one out myself if I'd been able to consult a list of what's available.
Re: Can a macro address tracked changes?
Help > Macro Language Referencechazzo wrote:Taking a wider view, is there a reference somewhere for all these macro properties? I'm extremely grateful for the help, but I could probably have figured this one out myself if I'd been able to consult a list of what's available.
What do you mean by "Text Language Changed"? Are you talking about the language attribute? In that case you would have to get the attributes using ".originalTextAttributes". This is itself another object. But all of this is documented in the above mentioned file.
philip
Re: Can a macro address tracked changes?
I feel pretty stupid now, but thank you.phspaelti wrote:Help > Macro Language Reference
I meant that your "if ! $change.isTextContentChanged" condition finds:phspaelti wrote:What do you mean by "Text Language Changed"? Are you talking about the language attribute? In that case you would have to get the attributes using ".originalTextAttributes". This is itself another object. But all of this is documented in the above mentioned file.
Formatted: Font: Georgia; was: Times New Roman
but not:
Formatted: Language: English (U.S.); was: German
And "if $change.isTextAttributesChanged" does not seem to work either, So yes, I guess I need to get ".originalTextAttributes.language" and compare it to the current language attribute. Thanks for the tip.
Re: Can a macro address tracked changes?
That sounds like a bug to me. You should report it (using Feedback.)chazzo wrote:I meant that your "if ! $change.isTextContentChanged" condition finds:
Formatted: Font: Georgia; was: Times New Roman
but not:
Formatted: Language: English (U.S.); was: German
philip
Re: Can a macro address tracked changes?
I think it's a bug in my document after too many exchanges with Word users. I tried it on a clean document and it's fine.phspaelti wrote:That sounds like a bug to me. You should report it (using Feedback.)
Looking more closely at what happens when I run the macro on my working document: some of the language changes are indeed accepted. The ones that aren't seem to be orphans: they are not actually attached to text in the document. I hadn't noticed that before. It's not surprising that the macro doesn't deal with them.
Aaargh! I hate Word but I can't avoid working with people who use it. And these are the "nice" clients, who stick to RTF...
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Can a macro address tracked changes?
Even if the problem is related to Word or too many file exchanges, we'd still be happy to take a look at your file and see if we can't fix the problem. If you don't mind, please send it to us privately using the menu Help > Send Feedback so we can see what can be done. Thanks!chazzo wrote:I think it's a bug in my document after too many exchanges with Word users. I tried it on a clean document and it's fine.phspaelti wrote:That sounds like a bug to me. You should report it (using Feedback.)
Looking more closely at what happens when I run the macro on my working document: some of the language changes are indeed accepted. The ones that aren't seem to be orphans: they are not actually attached to text in the document. I hadn't noticed that before. It's not surprising that the macro doesn't deal with them.
Aaargh! I hate Word but I can't avoid working with people who use it. And these are the "nice" clients, who stick to RTF...
Re: Can a macro address tracked changes?
Thanks Martin -- I've done that.If you don't mind, please send it to us privately using the menu Help > Send Feedback so we can see what can be done. Thanks!
Charles
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Can a macro address tracked changes?
Thanks Charles, I see the report you submitted and we'll reply to you privately.
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Can a macro address tracked changes?
The tracked changes the macro is missing are actually changes applied in your document's footnote text areas. The problem is that the ".allTrackedChanges" command doesn't return those changes, which is a bug we'll have to fix. Sorry about that.chazzo wrote:Looking more closely at what happens when I run the macro on my working document: some of the language changes are indeed accepted. The ones that aren't seem to be orphans: they are not actually attached to text in the document.
Here's another macro that (mostly) works around that:
Code: Select all
$doc = Document.active
$docText = $doc.text
$lastDocTextLoc = 0
# iterate all changes in the document
Select Document Start
While TRUE
Menu "Go To Next Change"
$selected = TextSelection.active
$text = $selected.text
# accept formatting changes
$changes = $text.trackedChangesAtIndex($selected.location)
If $changes
ForEach $change in $changes
If ! $change.isTextContentChanged
$change.accept
End
End
End
# check if wrapped
If $text == $docText
If $selected.location < $lastDocTextLoc
Break
End
$lastDocTextLoc = $selected.location
End
End
Re: Can a macro address tracked changes?
Thanks Martin, that's very helpful.