How to Quickly Highlight All Table Cells Containing Specific Text in Outlook Email

If you need to quickly find out and highlight the table cells containing the specific text in an email, you can use the method shared in this article.

As we all know, to highlight the specific text in an Outlook email, we can simply use the “Find & Replace” feature. However, what to do if you want to highlight the table cells containing the specific text? In that instance, you’ve limited the search scope to the tables only instead of the whole email body. Also, it aims to highlight the table cells instead of the texts. Thus, it’s exceeded what “Find & Replace” can do. But don’t worry. Thereinafter, we will teach you a method to get it. Read on to get its details.

Highlight All Table Cells Containing Specific Text in Email

  1. At the very beginning, launch Outlook application.
  2. Then, go to VBA editor window via “Alt + F11”.
  3. Next, enable “MS Word Object” by following “How to Add an Object Library Reference in VBA“.
  4. After that, put the following VBA code into an unused module.
Sub HighlightTableCellsContainingSpecificText()
    Dim objMail As Outlook.MailItem
    Dim objMailDocument As Word.Document
    Dim strText
 
    'Get the current email
    Set objMail = Outlook.Application.ActiveInspector.CurrentItem
    Set objMailDocument = objMail.GetInspector.WordEditor
    'Enter the specific text
    strText = InputBox("Enter the specific text to be found:", , "DataNumen Outlook Repair")
 
    With objMailDocument.Range
        With .Find
             .ClearFormatting
             .Replacement.ClearFormatting
             .Text = strText
             .Replacement.Text = ""
             .Forward = True
             .Wrap = wdFindStop
             .Execute
       End With
 
       'Highlight the table cells containing the specific text
       Do Until .Find.Found = False
          If .Information(wdWithInTable) = True Then
             .Cells(1).Shading.BackgroundPatternColorIndex = wdPink
          End If
          .Collapse wdCollapseEnd
          .Find.Execute
       Loop
    End With
End Sub

VBA Code - Highlight All Table Cells Containing Specific Text in Email

  1. Later, follow “Optional Step” introduced in the “How to Run VBA Code in Your Outlook” to add this macro to Quick Access Toolbar of Message window.
  2. Finally, you can take a shot.
  • First off, open the email which has multiple tables.
  • Then, click the macro button in Quick Access Toolbar.
  • Next, type the specific text in the popup input box.Input Specific Text
  • After you clicking “OK”, macro will rapidly find the table cells containing the specific text and highlight them in the predefined color, as shown in the following figure.Highlighted Table Cells

Defend Outlook File against Corruption

Have you ever come across any serious issues in your Outlook, like sudden crash or freezing? Under those circumstances, Outlook file is exactly prone to damage. Thus, you should make adequate precautions to prevent them. For instance, you have to keep monitoring your Outlook file health, make regular Outlook backups as well as preparing a potent Outlook repair utility, such as DataNumen Outlook Repair.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupt SQL Server and outlook repair software products. For more information visit www.datanumen.com