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: 18:09
+ ...
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: 01:09
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: 01:09
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: 18:09
+ ...
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

Across v6.3
Translation Toolkit and Sales Potential under One Roof

Apart from features that enable you to translate more efficiently, the new Across Translator Edition v6.3 comprises your crossMarket membership. The new online network for Across users assists you in exploring new sales potential and generating revenue.

More info »
Déjà Vu X3
Try it, Love it

Find out why Déjà Vu is today the most flexible, customizable and user-friendly tool on the market. See the brand new features in action: *Completely redesigned user interface *Live Preview *Inline spell checking *Inline

More info »

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