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

Claudia Alvis  Identity Verified
Peru
Local time: 18:04
Member
Spanish
+ ...
Nov 12, 2008

Hi,

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.

Thanks.


 

Jerzy Czopik  Identity Verified
Germany
Local time: 01:04
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.

 

Antoní­n Otáhal
Local time: 01:04
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:


Code:

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

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:


Code:

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

begg:
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
endd:
LTL = CInt(iint)
nochange:
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.

Antonin


 

Claudia Alvis  Identity Verified
Peru
Local time: 18:04
Member
Spanish
+ ...
TOPIC STARTER
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.

Cheers,

Claudia


 


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






BaccS – Business Accounting Software
Modern desktop project management for freelance translators

BaccS makes it easy for translators to manage their projects, schedule tasks, create invoices, and view highly customizable reports. User-friendly, ProZ.com integration, community-driven development – a few reasons BaccS is trusted by translators!

More info »
WordFinder Unlimited
For clarity and excellence

WordFinder is the leading dictionary service that gives you the words you want anywhere, anytime. Access 260+ dictionaries from the world's leading dictionary publishers in virtually any device. Find the right word anywhere, anytime - online or offline.

More info »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search