MS Word macro to manipulate tracked text Thread poster: Samuel Murray
| Samuel Murray Netherlands Local time: 21:53 Member (2006) English to Afrikaans + ...
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 Netherlands Local time: 21:53 Member (2006) English to Afrikaans + ... TOPIC STARTER
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) Netherlands Local time: 21:53
How about going for the xml inside the docx zip package? | | | Rolf Keller Germany Local time: 21:53 English to German 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 Netherlands Local time: 21:53 Member (2006) English to Afrikaans + ... TOPIC STARTER
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 Germany Local time: 21:53 English to German 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 Protemos translation business management system | Create your account in minutes, and start working! 3-month trial for agencies, and free for freelancers!
The system lets you keep client/vendor database, with contacts and rates, manage projects and assign jobs to vendors, issue invoices, track payments, store and manage project files, generate business reports on turnover profit per client/manager etc.
More info » |
| Trados Business Manager Lite | Create customer quotes and invoices from within Trados Studio
Trados Business Manager Lite helps to simplify and speed up some of the daily tasks, such as invoicing and reporting, associated with running your freelance translation business.
More info » |
|
| | | | X Sign in to your ProZ.com account... | | | | | |