How do I "tell" a macro that it should be applied only to the selected text
Thread poster: Claudia Alvis

Claudia Alvis  Identity Verified
Local time: 22:08
+ ...
Nov 12, 2008


I created a few macros to modify the font of the text. I used the Search & Replace function, but now I can't figure out how do I "tell" the Macros that they should only be applied to the selection. Or better yet (althought this might be waaay more complex), is there a way to "tell" the Macros that they should be applied ONLY to the text in the target segment (Trados).
I'm using Word 2003 and the Visual Basic editor.


Direct link Reply with quote

Jerzy Czopik  Identity Verified
Local time: 04:08
Member (2003)
Polish to German
+ ...
Use the formatting option Nov 12, 2008

When using S&R function, you can chose whether to replace hidden or not hidden text. Same should be possible when programming a macro.

Direct link Reply with quote

Antoní­n Otáhal
Local time: 04:08
Member (2005)
English to Czech
+ ...
VBA Nov 12, 2008

(1) eplace in selection:

This text, if inserted in a macro, will replace "cca" wïth "approx." in the selection:



With Selection.Find
.Text = "cca"
.Replacement.Text = "approx."
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Selection.Find.Execute Replace:=wdReplaceAll
End With

(2) Trados in Word macros

I have a set of macros applied to only source or target segments in Workbench+Word combination (though rarely used nowadays). Since I work cz to uk or us and vice versa, I put the selection of this aspect as a parameter there:


Sub Set_LTL()
Dim iint As String
stringexpl = "LTL = 0 ... cz to uk" & vbCrLf
stringexpl = stringexpl & "LTL = 1 ... uk to cz" & vbCrLf
stringexpl = stringexpl & "LTL = 2 ... cz to us" & vbCrLf
stringexpl = stringexpl & "LTL = 3 ... us to cz" & vbCrLf

iint = InputBox(stringexpl & vbCrLf & "LTL value is " & LTL & vbCrLf & vbCrLf & "Set LTL" )
If iint = "" Then GoTo nochange
If iint = "0" Or iint = "1" Or iint = "2" Or iint = "3" Then GoTo endd
GoTo begg
LTL = CInt(iint)
End Sub

Depending on that, I preprocess and postprocess the segments in Word (text colours, language settings of the font, etc.).

Frankly, I do not think it is worth the effort anymore (if I do use Trados, it is usually TagEditor); but if you feel like having those old macros of mine, no problem - let me know.


Direct link Reply with quote

Claudia Alvis  Identity Verified
Local time: 22:08
+ ...
Thanks! Nov 12, 2008

Thank you so much again Antonín. The problem I have is that I want change the format to all the characters in a particular segment, but I can't figure out what to put in the Replacement line. Using .Replacement.Text = "" deletes everything of course. So I created multiples macros and moved them to a toolbar, so now I'm selecting the text manually and using the different macros to modify the fonts.

I'm translating a revision of a document that is based on another revision of a very similar document (so I'm basically working with 4 files simultaneously). But in the first revision, italics were used to highlight the additions, and in my version, a different font was used (non-italic, different color, different size, different effects). Also, different colors mean different kind of changes in both documents. And since the documents are not 100% per cent similar, I need to see the colors to know where I apply the changes, so TagEditor is out of the question.

But you're second Macro is fantastic. I think I can modify it a little and use it to fix some TMs that are a sub-languages nightmare.



Direct link Reply with quote

To report site rules violations or get help, contact a site moderator:

You can also contact site staff by submitting a support request »

How do I "tell" a macro that it should be applied only to the selected text

Advanced search

Manage your TMs and Terms ... and boost your translation business

Are you ready for something fresh in the industry? TM-Town is a unique new site for you -- the freelance translator -- to store, manage and share translation memories (TMs) and glossaries...and potentially meet new clients on the basis of your prior work.

More info »
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 »

  • All of
  • Term search
  • Jobs
  • Forums
  • Multiple search