MS Word macro to manipulate tracked text თემის ავტორი: Samuel Murray
| Samuel Murray ნიდერლანდები Local time: 01:38 წევრი (2006) ინგლისური -> აფრიკაანსი + ...
Hello everyone
Does anyone know of a macro that will modify a tracked changes document in MS Word so that it adds curly brackets on either side of a deletion and square brackets on either side of an insertion?
It doesn't matter to me if the brackets close whole chunks of deletions or insertions, or deleted or inserted characters individually, nor does it matter to me if the tracks remain intact and/or if the brackets are tracked.
Here are two examples of wh... See more Hello everyone
Does anyone know of a macro that will modify a tracked changes document in MS Word so that it adds curly brackets on either side of a deletion and square brackets on either side of an insertion?
It doesn't matter to me if the brackets close whole chunks of deletions or insertions, or deleted or inserted characters individually, nor does it matter to me if the tracks remain intact and/or if the brackets are tracked.
Here are two examples of what I'm looking for (any of the 6 options shown under the example would be acceptable to me, though I would prefer the third one, i.e. nothing in tracks anymore, and whole tracked sections bracketed):


I need this so that I can add tracked text to my TM.
Thanks
Samuel
[Edited at 2016-10-20 14:21 GMT]
[Edited at 2016-10-20 14:23 GMT] ▲ Collapse | | | Samuel Murray ნიდერლანდები Local time: 01:38 წევრი (2006) ინგლისური -> აფრიკაანსი + ... თემის ავტორი
Samuel Murray wrote:
Does anyone know of a macro that will modify a tracked changes document in MS Word so that it adds curly brackets on either side of a deletion and square brackets on either side of an insertion?
This one works, but only on short documents, and it sometimes forgets to process the last deletion/insertion in the file:
Sub tracks2brackets()
' Based on code from: http://www.wordbanter.com/showthread.php?t=68482
' and http://wordribbon.tips.net/T012055_Automatically_Inserting_Brackets.html
' (this is a combination of two macros)
ActiveDocument.TrackRevisions = False
Number = ActiveDocument.Revisions.Count
For x = 1 To Number
Set myRev = ActiveDocument.Revisions(x).Range
This = ActiveDocument.Revisions(x).Type
If This = 2 Then
myRev.Select
Selection.InsertAfter "›"
Selection.InsertBefore "‹"
End If
If This = 1 Then
myRev.Select
Selection.InsertAfter "»"
Selection.InsertBefore "«"
End If
Next x
Dim chgAdd As Word.Revision
ActiveDocument.TrackRevisions = False
For Each chgAdd In ActiveDocument.Revisions
If chgAdd.Type = wdRevisionDelete Then
chgAdd.Reject
ElseIf chgAdd.Type = wdRevisionInsert Then
chgAdd.Accept
End If
Next chgAdd
End Sub | | | CafeTran Training (X) ნიდერლანდები Local time: 01:38
How about going for the xml inside the docx zip package? | | | Rolf Keller გერმანია Local time: 01:38 ინგლისური -> გერმანული Optimize the macro | Oct 21, 2016 |
Samuel Murray wrote:
This one works, but only on short documents
Maybe some code parts run to slow and produce racing conditions.
(1) Suppress unnecessary screen updates by encapsulating the code:
Sub tracks2brackets()
Application.ScreenUpdating = False
... your existing Sub body goes here ...
Application.ScreenUpdating = True
end Sub
(2) Make the code faster by using only one insert instead of two:
Replace
Selection.InsertAfter "›"
Selection.InsertBefore "‹"
by
Selection = "›" + Selection + "‹" | |
|
|
Samuel Murray ნიდერლანდები Local time: 01:38 წევრი (2006) ინგლისური -> აფრიკაანსი + ... თემის ავტორი
Rolf Keller wrote:
(2) Make the code faster by using only one insert instead of two:
Replace
Selection.InsertAfter "›"
Selection.InsertBefore "‹"
by
Selection = "‹" + Selection + "›"
Thanks, but... unfortunately, if I do this, then the macro only works on deletions, and it ignores insertions.
(1) Suppress unnecessary screen updates by encapsulating the code:
Sub tracks2brackets()
Application.ScreenUpdating = False
... your existing Sub body goes here ...
Application.ScreenUpdating = True
end Sub
This seems to have an effect but since the screen doesn't update, it becomes difficult to tell whether Word is still working. | | | Rolf Keller გერმანია Local time: 01:38 ინგლისური -> გერმანული Macro enhancements, continued | Oct 21, 2016 |
Samuel Murray wrote:
if I do this, then the macro only works on deletions, and it ignores insertions.
I swapped the angle brackets, sorry.
since the screen doesn't update, it becomes difficult to tell whether Word is still working.
The standard solution for this is a messagebox. Just insert
MsgBox "Done!"
at the end. | | | To report site rules violations or get help, contact a site moderator: You can also contact site staff by submitting a support request » MS Word macro to manipulate tracked text CafeTran Espresso | You've never met a CAT tool this clever!
Translate faster & easier, using a sophisticated CAT tool built by a translator / developer.
Accept jobs from clients who use Trados, MemoQ, Wordfast & major CAT tools.
Download and start using CafeTran Espresso -- for free
Buy now! » |
| Trados Studio 2022 Freelance | The leading translation software used by over 270,000 translators.
Designed with your feedback in mind, Trados Studio 2022 delivers an unrivalled, powerful desktop
and cloud solution, empowering you to work in the most efficient and cost-effective way.
More info » |
|
| | | | X Sign in to your ProZ.com account... | | | | | |