Reply to topic  [ 13 posts ] 
Can a macro address tracked changes? 
Author Message
User avatar

Joined: 2011-10-27 03:40:31
Posts: 25
Location: Norfolk, UK
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


2013-02-19 11:02:03
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
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


2013-02-19 15:13:39
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
This macro would seem to do the trick (Test it on a copy, please!).

Code:
$doc = Document.active
$changes = $doc.allTrackedChanges
foreach $change in $changes
   if ! $change.isTextContentChanged
      $change.accept
   end
end

_________________
philip


2013-02-19 15:27:56
Profile
User avatar

Joined: 2011-10-27 03:40:31
Posts: 25
Location: Norfolk, UK
Quote:
This macro would seem to do the trick


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.

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.


2013-02-20 02:10:24
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
chazzo 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.


Help > Macro Language Reference

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


2013-02-20 04:58:38
Profile
User avatar

Joined: 2011-10-27 03:40:31
Posts: 25
Location: Norfolk, UK
phspaelti wrote:
Help > Macro Language Reference


I feel pretty stupid now, but thank you.

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.


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

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.


2013-02-20 06:55:14
Profile
User avatar

Joined: 2007-02-07 00:58:12
Posts: 876
Location: Japan
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


That sounds like a bug to me. You should report it (using Feedback.)

_________________
philip


2013-02-20 07:31:46
Profile
User avatar

Joined: 2011-10-27 03:40:31
Posts: 25
Location: Norfolk, UK
phspaelti wrote:
That sounds like a bug to me. You should report it (using Feedback.)


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.

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


2013-02-20 08:43:47
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
chazzo wrote:
phspaelti wrote:
That sounds like a bug to me. You should report it (using Feedback.)


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.

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

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!


2013-02-21 18:53:42
Profile WWW
User avatar

Joined: 2011-10-27 03:40:31
Posts: 25
Location: Norfolk, UK
Quote:
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!


Thanks Martin -- I've done that.
Charles


2013-02-22 03:24:24
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Thanks Charles, I see the report you submitted and we'll reply to you privately.


2013-02-22 13:05:00
Profile WWW
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
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.

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.

Here's another macro that (mostly) works around that:
Code:
$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

I say "almost" works around the problem because this macro still misses a few changes in your file. There are about 3 changes which aren't visited properly, due to a related bug which is triggered by the particular way the changes and footnote references overlap.


2013-02-22 18:32:12
Profile WWW
User avatar

Joined: 2011-10-27 03:40:31
Posts: 25
Location: Norfolk, UK
Thanks Martin, that's very helpful.


2013-02-24 11:07:46
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 13 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software