macro to delete "tracks" containing certain characters
-
- Posts: 158
- Joined: 2007-01-17 05:46:17
- Location: Tokyo, Japan
- Contact:
macro to delete "tracks" containing certain characters
Hello,
I am editing a file containing an enormous number of "track changes -- and I notice that NWP is very weak to deal with this kind of documents. If I open and edit it in MS Word, there are almost no problems, but in NWP, each change takes minutes and each time, the rainbow wheel is turning indefinitly... I really would like to request a better treatment of this kind of documents...
Anyway, this enormous number of "track changes" is the result of several "change all" for formatting. The editor who made these changes made "change all" to change all the spaces after "«" and before "»" into "non-breaking spaces". This is correct in terms of editing process, but leaving all these changes in "track changes" seems to me a rather silly thing...
Anyway, what I would love to have is a macro that would select every instance of "track change" which contains a "non-breaking space". Is such a macro possible?
Thank you very much in advance to whoever would be so kind as to write for me this macro...
Best regards,
Nobumi
I am editing a file containing an enormous number of "track changes -- and I notice that NWP is very weak to deal with this kind of documents. If I open and edit it in MS Word, there are almost no problems, but in NWP, each change takes minutes and each time, the rainbow wheel is turning indefinitly... I really would like to request a better treatment of this kind of documents...
Anyway, this enormous number of "track changes" is the result of several "change all" for formatting. The editor who made these changes made "change all" to change all the spaces after "«" and before "»" into "non-breaking spaces". This is correct in terms of editing process, but leaving all these changes in "track changes" seems to me a rather silly thing...
Anyway, what I would love to have is a macro that would select every instance of "track change" which contains a "non-breaking space". Is such a macro possible?
Thank you very much in advance to whoever would be so kind as to write for me this macro...
Best regards,
Nobumi
Best regards,
Nobumi Iyanaga
Tokyo,
Japan
Nobumi Iyanaga
Tokyo,
Japan
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: macro to delete "tracks" containing certain characters
Hi Nobumi,
Here's a macro that finds text in tracked changes. It will search all tracked deletions and replacements in your document, selecting those whose original (ie: deleted) text matches the search text. You can then either accept or reject them all.
As an aside, are you able to send us your document privately, so I can see the slowdown firsthand? I'd like to see if there's anything we can do to help Nisus Writer behave more smoothly. Thanks!
Here's a macro that finds text in tracked changes. It will search all tracked deletions and replacements in your document, selecting those whose original (ie: deleted) text matches the search text. You can then either accept or reject them all.
As an aside, are you able to send us your document privately, so I can see the slowdown firsthand? I'd like to see if there's anything we can do to help Nisus Writer behave more smoothly. Thanks!
-
- Posts: 158
- Joined: 2007-01-17 05:46:17
- Location: Tokyo, Japan
- Contact:
Re: macro to delete "tracks" containing certain characters
Hello Martin,
Thank you for your reply and your excellent macro!
You wrote:
It seems that NWP macro language lacks the " property among the TrackedChange Object Properties. But going through the " or ""..., it seems possible to get the values of the added text?? The macro would be much more complicated, but is it possible to write such a macro, please...?
Thank you very much in advance!
You wrote also:
Best regard,
Nobumi Iyanaga
Thank you for your reply and your excellent macro!
You wrote:
The macro worked very well. I could delete (that is, accept) more than 300 changes. -- But there are much more of the same kind, in which no traces of deleted text seem to be left; there are only the added elements which are indicated in the side bar...Here's a macro that finds text in tracked changes. It will search all tracked deletions and replacements in your document, selecting those whose original (ie: deleted) text matches the search text. You can then either accept or reject them all.
It seems that NWP macro language lacks the "
Code: Select all
.addedTextContent"
Code: Select all
.markedText"
Code: Select all
.markedTextRange
Thank you very much in advance!
You wrote also:
Yes, surely. I will send you the file in a feedback. Thank you in advance for examining it, and see how it would be possible to improve NWP's behavior.As an aside, are you able to send us your document privately, so I can see the slowdown firsthand? I'd like to see if there's anything we can do to help Nisus Writer behave more smoothly. Thanks!
Best regard,
Nobumi Iyanaga
Best regards,
Nobumi Iyanaga
Tokyo,
Japan
Nobumi Iyanaga
Tokyo,
Japan
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: macro to delete "tracks" containing certain characters
I'm very happy to help!
Ah yes, I should have anticipated this need. Here's an amended macro that can search tracked deletions and additions.Nobumi Iyanaga wrote:The macro worked very well. I could delete (that is, accept) more than 300 changes. -- But there are much more of the same kind, in which no traces of deleted text seem to be left; there are only the added elements which are indicated in the side bar...
Yes, the trick is to set the selection to the marked text/range and then search only within the selection. You can see how it works in the updated macro.It seems that NWP macro language lacks the "property among the TrackedChange Object Properties. But going through the "Code: Select all
.addedTextContent"
or "Code: Select all
.markedText"
"..., it seems possible to get the values of the added text??Code: Select all
.markedTextRange
Great, I'll be on the lookout for it, thank you!Yes, surely. I will send you the file in a feedback.
Re: macro to delete "tracks" containing certain characters
You should be able to useNobumi Iyanaga wrote: It seems that NWP macro language lacks the "property among the TrackedChange Object Properties. But going through the "Code: Select all
.addedTextContent"
or "Code: Select all
.markedText"
"..., it seems possible to get the values of the added text?? The macro would be much more complicated, but is it possible to write such a macro, please...?Code: Select all
.markedTextRange
Code: Select all
$addedText = $change.markedText.subtextInRange($change.markedTextRange)
The range value for the main text would have to be calculated with something like this:
Code: Select all
$isMatch = $addedText.find($findText, $findOps)
if $isMatch
$findRange = Range.new $change.markedTextRange.location + $isMatch.location, $isMatch.length
end
philip
-
- Posts: 158
- Joined: 2007-01-17 05:46:17
- Location: Tokyo, Japan
- Contact:
Re: macro to delete "tracks" containing certain characters
Hello Martin,
Hello Philip,
Thank you for your new macro, Martin. I downloaded it and used it. It works perfectly, as I have expected. This helped much, and now, with much less "track changes", I can edit my document without difficulties. Thank you very much again!
As Philip points out, you use "GUI Find" to test if a track changed text contains an added item that matches those items to be found -- and this seems to slow down the macro...? But this is not a major problem; anyway, with your macro, I could make the file "workable".
Philip's codes seem very interesting, but I don't understand how they should be inserted in Martin's macro.
Anyway, I find that it is rather not very intelligent to record these kinds of "Replace All" in track changes (for example Replace All every space with a non-breaking-space for cases like "« " or " »", etc.); but there are certainly people who do that. NWP should be able to deal with this kind of files too...
Best regard,
Nobumi Iyanaga
Hello Philip,
Thank you for your new macro, Martin. I downloaded it and used it. It works perfectly, as I have expected. This helped much, and now, with much less "track changes", I can edit my document without difficulties. Thank you very much again!
As Philip points out, you use "GUI Find" to test if a track changed text contains an added item that matches those items to be found -- and this seems to slow down the macro...? But this is not a major problem; anyway, with your macro, I could make the file "workable".
Philip's codes seem very interesting, but I don't understand how they should be inserted in Martin's macro.
Anyway, I find that it is rather not very intelligent to record these kinds of "Replace All" in track changes (for example Replace All every space with a non-breaking-space for cases like "« " or " »", etc.); but there are certainly people who do that. NWP should be able to deal with this kind of files too...
Best regard,
Nobumi Iyanaga
Best regards,
Nobumi Iyanaga
Tokyo,
Japan
Nobumi Iyanaga
Tokyo,
Japan
Re: macro to delete "tracks" containing certain characters
Hello Nobumi,
Martin's code:
Changed code:
Here is a copy of the macro with the change included.
I had a more careful look at Martin's code, and I see that he doesn't make use of the find on the added text after all. He really just checks for presence of the find text. So the change to the macro is really simple:Nobumi Iyanaga wrote:Philip's codes seem very interesting, but I don't understand how they should be inserted in Martin's macro.
Martin's code:
Code: Select all
If $isSearchAdditions
$markedText = $change.markedText
If $markedText
$markedRange = $change.markedTextRange
If $markedRange
$select = TextSelection.new($markedText, $markedRange)
$doc.setSelection($select)
If Find $findText, "s$findOps"
$isMatch = @TRUE
End
End
End
End
Code: Select all
If $isSearchAdditions
$markedText = $change.markedText
If $markedText
$markedRange = $change.markedTextRange
If $markedRange
$addedText = $markedText.subtextInRange($markedRange)
$isMatch = $addedText.find($findText, $findOps)
End
End
End
This problem strikes me as the fundamental problem with Tracked Changes and why I never use them in the first place. The machine simply has no way to know the difference between a meaningful change and a cosmetic change. So unless you constantly weed through the changes and accept the cosmetic ones you end up with a document heavy with changes, and you end up with a "needle in the haystack" problem. Managing the changes can be more work than is gained by tracking them.Nobumi Iyanaga wrote: Anyway, I find that it is rather not very intelligent to record these kinds of "Replace All" in track changes (for example Replace All every space with a non-breaking-space for cases like "« " or " »", etc.); but there are certainly people who do that. NWP should be able to deal with this kind of files too...
philip