#1
|
|||
|
|||
Hide all text in shaded table cells
Hello everyone
I'm a translator, and my translation software can exclude text from the translation process if the text font is marked as "hidden". I have now received two MS Word files from a client, with these requirements: in the one file, I have to translate only the text in non-shaded table cells; in the other file, I have to translate only the text in table cells that are not shaded in green. So, do you know of a macro or macros that can do that? I.e., (1) find all table cells that have shaded backgrounds, and mark the text in them as "hidden" or as some other font specification, and (2) find all table cells that have green shaded background, and mark the text in them as "hidden" or a different font. I've attached a sample document so that you can see what I mean by "shaded background". Alternatively, can you point me in some direction about how to specify these attributes in an edited recorded macro? Thanks Samuel |
#2
|
||||
|
||||
Provided the green colour is that shown in the sample, the following will mark the text in those green cells as hidden/unhidden.
Code:
Sub ToggleTextInGreenCells() Dim oTable As Table Dim oCell As Cell Dim oRng As Range For Each oTable In ActiveDocument.Tables For Each oCell In oTable.Range.Cells If oCell.Shading.BackgroundPatternColor = RGB(194, 214, 155) Then Set oRng = oCell.Range oRng.End = oRng.End - 1 If oRng.Font.Hidden = True Then oRng.Font.Hidden = False Else oRng.Font.Hidden = True End If End If Next oCell Next oTable lbl_Exit: Set oTable = Nothing Set oCell = Nothing Set oRng = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Quote:
The grey cell in my sample file doesn't show an RGB value when I click in it and make as if I want to change the shade colour -- does that mean that that cell is not shaded but that it's greyish background colour is due to something else? == Added: After a bit of tinkering I figure out how to mark that cell's text as hidden, too: Code:
If oCell.Shading.Texture = wdTexture10Percent Then Do you know what method I must use to hide the text in the darker grey cells on the second page of the sample2.doc file? == Added2: Oh, I figured it out -- the darker grey is 191, 191, 191. But my woes continued. Elsewhere in the file (sample not attached) is a cell whose greyness is indicated by the borders&shading dialog as "Grey -15%". Sigh... but then I found out that that was just MS Word's say of saying 217, 217, 217. Samuel |
#4
|
||||
|
||||
The easiest way to get the colour is to sample it and you can do that most easily with the utility ColorCop.
In your attachment the background shading colour of the grey cell is RGB(229,229,229)
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to make a style with shaded background and indented text? | Katarina | Word | 4 | 03-25-2014 01:12 AM |
Cells no longer wrap text when changed in nested table | erik2000 | Word Tables | 1 | 03-29-2013 03:27 PM |
Word document with shaded table fields | davidingilbert | Word | 3 | 11-20-2012 12:18 PM |
put a border around table cells that have text in them | tonywatsonmail | Mail Merge | 1 | 01-31-2012 04:37 AM |
Combining Text from Table Cells | robmorleyuk | Word | 1 | 11-01-2011 07:24 AM |