Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 08-08-2019, 02:02 AM
gmayor's Avatar
gmayor gmayor is offline Text Background Colour in a Table Windows 10 Text Background Colour in a Table Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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 ofgmayor has much to be proud of
Default

If you mean in the merge document itself then the following macro will do that.

Code:
Sub Macro1()
Dim oCell As Cell
Dim oFld As Field
    For Each oCell In ActiveDocument.Tables(1).Range.Cells
        For Each oFld In oCell.Range.Fields
            If oFld.Type = wdFieldMergeField Then
                If InStr(1, oFld.Code, "Product") > 0 Or _
                   InStr(1, oFld.Code, "Desc") > 0 Then
                    oCell.Shading.BackgroundPatternColor = wdColorWhite
                    Exit For
                Else
                    oCell.Shading.BackgroundPatternColor = &HD9D9D9
                End If
            End If
        Next oFld
    Next oCell
lbl_Exit:
    Set oCell = Nothing
    Set oFld = 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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word background colour ignores Windows setting wiganken Word 1 07-19-2018 09:25 AM
Text Background Colour in a Table Changing background colour based on dropdown choice PLeo Word VBA 2 08-03-2017 07:40 AM
Text Background Colour in a Table VBA Table – Search All Tables - Find & Replace Text in Table Cell With Specific Background Color jc491 Word VBA 8 09-30-2015 06:10 AM
Word VBA Find Table Text Shading Colour and replace with another QA_Compliance_Advisor Word VBA 10 09-19-2014 08:36 AM
Trying to clear the background colour from a theme ezekiel181 Word 1 11-14-2010 07:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:09 PM.


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