VB script to search background colour in Word? Thread poster: Jan Sundström
|
Hi all, I have a Word document that consists of several two-column tables. If it was one long table, it would be no trouble, but there are 50-over separate tables, interspersed with graphical objects and page breaks. Like this: --- | English source text (do not touch) | Copy of English source text to be translated | --- The left column has a blue background, but the actual text formatting is identical in both columns. I wanted to ma... See more Hi all, I have a Word document that consists of several two-column tables. If it was one long table, it would be no trouble, but there are 50-over separate tables, interspersed with graphical objects and page breaks. Like this: --- | English source text (do not touch) | Copy of English source text to be translated | --- The left column has a blue background, but the actual text formatting is identical in both columns. I wanted to make a search/replace with the Pattern Matching in Word, that way I could apply tw4WinExternal to the left columns. But no option exists to search for background colour! Does anyone know if this would be possible to achieve through writing a VB script? I found some resources online indicating that it's possible, but I have no clue how to program VB: http://builder.oflameron.ru/ http://www.tek-tips.com/viewthread.cfm?qid=1442506&page=9 Or do you have other ideas how to solve this nut?! /J ▲ Collapse | | | Jaroslaw Michalak Poland Local time: 23:24 Member (2004) English to Polish SITE LOCALIZER
It is possible with VBA (I assume you meant it as a Word macro?), but first I would try a different approach: just mark the first column of all tables. But for that I would have to be sure that it is always that particular column which needs to be marked... If it is so, here's the macro: Code:
|
Sub ExternalizeFirstColumn() ... See moreIt is possible with VBA (I assume you meant it as a Word macro?), but first I would try a different approach: just mark the first column of all tables. But for that I would have to be sure that it is always that particular column which needs to be marked... If it is so, here's the macro: Code:
|
Sub ExternalizeFirstColumn()
For Each aTable In ActiveDocument.Tables
aTable.Columns(1).Select
Selection.Style = "tw4WinExternal"
Next
End Sub
|
|
It works here, but of course try it out on a copy...
[Edited at 2009-02-27 19:39 GMT] ▲ Collapse | | Vito Smolej Germany Local time: 23:24 Member (2004) English to Slovenian + ... SITE LOCALIZER why not DO-NOT-TRANSLATE style | Feb 27, 2009 |
Hi Jan: what you want to do, is taken care of by DO NO TRANSLATE style. Just Mark all those texts you want unchanged as DO_NO_TRANSLATE. I do not know, however, how it looks, when you have to change the style back to the original - but that's the same problem also, when painting everything with tw4WinExternal. Or am I missing the point? The gut feeling is "you cant have a cake and eat it too": changing styles is what it says... | | | There is a problem with applying styles... | Feb 27, 2009 |
... and that is, the format of the text would be altered. It is better to apply an untranslatable attribute, such as Marching Red Ants, and then enable it in WF preferences. The macro would change from: Selection.Style = "tw4WinExternal" to: Selection.Font.Animation = wdAnimationMarchingRedAnts After translation (and/or cleanup), you do a Select All and choose Font > Animation > None. In this way, the source format is preserved. A ... See more ... and that is, the format of the text would be altered. It is better to apply an untranslatable attribute, such as Marching Red Ants, and then enable it in WF preferences. The macro would change from: Selection.Style = "tw4WinExternal" to: Selection.Font.Animation = wdAnimationMarchingRedAnts After translation (and/or cleanup), you do a Select All and choose Font > Animation > None. In this way, the source format is preserved. A further refinement would we to add a line below that one, stating: Selection.LanguageID = wdNoProofing so the spellckecker won't stop at this text. Daniel ▲ Collapse | |
|
|
DELETED double post | Feb 27, 2009 |
[Edited at 2009-02-27 22:37 GMT] | | | Jaroslaw Michalak Poland Local time: 23:24 Member (2004) English to Polish SITE LOCALIZER Styles and not | Feb 27, 2009 |
The Red Ants trick works only with WordFast, so it will not be good for Trados (I'm not sure which Jan is using). If the appearance of the text matters, it is enough to change the properties of the tw4WinExternal style - Trados only looks at the style name, not at particular font properties. Besides, changing one style with another with Find and Replace is rather trivial... | | | You are right, it's a WF thing... | Feb 28, 2009 |
... and he does not list it among his software. As regards this: changing one style with another with Find and Replace is rather trivial... A global style replacement won't work if you have two different styles to restore, as in this case, unless you perform it one-by-one. Daniel | | | Jan Sundström Sweden Local time: 23:24 English to Swedish + ... TOPIC STARTER You can't search for background colour :-( | Mar 3, 2009 |
Jabberwock wrote: Besides, changing one style with another with Find and Replace is rather trivial... Vito wrote: Just Mark all those texts you want unchanged as DO_NO_TRANSLATE. Hi all, Thanks a lot for your suggestions so far. Like Vito guessed however, I'm afraid most of you missed the point! My problem again: I have over 50 separate tables in each Word doc. I know how to mark each table individually and apply a style (or apply hidden text). But I'd have to do it 50 times over every time I get a new file. That's why I'd prefer a macro. I know how to search/replace in Word based on Pattern Matches (replace one colour with another colour, replace italics with bold, replace one style with another style). BUT: the problem is that Word doesn't allow searching for background colour! Check it for yourself, I could hardly believe it when I assumed to find the function and it was absent in the search window. /Jan | |
|
|
Jaroslaw Michalak Poland Local time: 23:24 Member (2004) English to Polish SITE LOCALIZER The macro is right there... | Mar 3, 2009 |
The macro I have given before allows to select the first column of every table and apply the style you want. Automatically, no manual searching required. The other comments concerned the case when you need to restore the formatting of the source, if it changes (although I believe it is not relevant in this case). | | | Jerzy Czopik Germany Local time: 23:24 Member (2003) Polish to German + ... Do not use styles | Mar 3, 2009 |
but just hidden text formatting and translate in Tageditor. If you do so, the only action you need after the translation is done is unhide the text. This way you can prevent Tageditor from accessing the text which should not be translated, but don't change the formatting of it. When you unhide it the formatting is exactly as it was before. | | | Jaroslaw Michalak Poland Local time: 23:24 Member (2004) English to Polish SITE LOCALIZER
If you prefer to hide the text instead of styling, replace the line: Selection.Style = "tw4WinExternal" with: Selection.Font.Hidden = True However, if different font properties are used within the cells, they might be made the same. Macros are somewhat inconsistent in this respect. | | | | To report site rules violations or get help, contact a site moderator: You can also contact site staff by submitting a support request » VB script to search background colour in Word? 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! » |
| 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 » |
|
| | | | X Sign in to your ProZ.com account... | | | | |
|
You can request verification for native languages by completing a simple application that takes only a couple of minutes.
Review native language verification applications submitted by your peers. Reviewing applications can be fun and only takes a few minutes.
View applications
|