Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-04-2015, 04:54 AM
ugcheleuce ugcheleuce is offline Hide all text in shaded table cells Windows 7 64bit Hide all text in shaded table cells Office 2003
Novice
Hide all text in shaded table cells
 
Join Date: Mar 2014
Location: Netherlands
Posts: 24
ugcheleuce is on a distinguished road
Default 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
Attached Files
File Type: doc sample.doc (43.0 KB, 8 views)
Reply With Quote
  #2  
Old 03-04-2015, 05:21 AM
gmayor's Avatar
gmayor gmayor is offline Hide all text in shaded table cells Windows 7 64bit Hide all text in shaded table cells Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,103
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #3  
Old 03-04-2015, 07:32 AM
ugcheleuce ugcheleuce is offline Hide all text in shaded table cells Windows 7 64bit Hide all text in shaded table cells Office 2003
Novice
Hide all text in shaded table cells
 
Join Date: Mar 2014
Location: Netherlands
Posts: 24
ugcheleuce is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
Provided the green colour is that shown in the sample, the following will mark the text in those green cells as hidden/unhidden.
Thanks, this really helps.

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
but... some other cells in my document (see sample2.doc) are a darker grey, and they don't respond to the updated macro, which leads me to suspect that they are shaded using an even diffent method.

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
Attached Files
File Type: doc sample2.doc (105.0 KB, 7 views)
Reply With Quote
  #4  
Old 03-04-2015, 10:28 PM
gmayor's Avatar
gmayor gmayor is offline Hide all text in shaded table cells Windows 7 64bit Hide all text in shaded table cells Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,103
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide all text in shaded table cells How to make a style with shaded background and indented text? Katarina Word 4 03-25-2014 01:12 AM
Hide all text in shaded table cells Cells no longer wrap text when changed in nested table erik2000 Word Tables 1 03-29-2013 03:27 PM
Hide all text in shaded table cells Word document with shaded table fields davidingilbert Word 3 11-20-2012 12:18 PM
Hide all text in shaded table cells put a border around table cells that have text in them tonywatsonmail Mail Merge 1 01-31-2012 04:37 AM
Hide all text in shaded table cells Combining Text from Table Cells robmorleyuk Word 1 11-01-2011 07:24 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:47 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft