2 Ways to Replace All Occurrences of a Specific Text with an Image in Outlook Email

When composing an Outlook mail, if you wish to quickly replace all the occurrences of a specific text with a specific image, you can use either of the 2 means shared in this article.

For some reasons, you may need to find all the occurrences of a specific text in an email and batch replace them with a specific picture. Some users think that this seems impossible. Actually, it can be easily achieved either via “Find and Replace” function or Outlook VBA code. In the followings, we will introduce them in detail.

2 Ways to Replace All Occurrences of a Specific Text with an Image in an Outlook Email

Method 1: Use “Find and Replace” Function

  1. At the very outset, in the source email window, you should switch to “Insert” tab and click “Picture”.
  2. In the new popup dialog box, select the specific image and hit “Insert”.Insert the Specific Image
  3. After the image is inserted in the message body, select it and press “Ctrl + C” key button to copy it.Copy Inserted Image
  4. Subsequently, you can delete the inserted image.
  5. Later, shift to “Format Text” tab and click “Replace” in “Editing” group.
  6. Next, in the popup “Find and Replace” dialog box, do the following steps:
  • First off, type the specific text in the “Find what” field.
  • Then, input “^c” in the “Replace with” field.
  • Lastly, click “Replace All” button.Replace Text with Image
  1. At once, you will find that all the occurrences of the specific text have been replaced with the specific image.Texts Replaced with Image

Method 2: Apply Outlook VBA Code

  1. For a start, keep the source email opened.
  2. Then, access VBA editor by referring to the article – “How to Run VBA Code in Your Outlook”.
  3. In the new window, enable “MS Word Object Library” according to the article – “How to Add an Object Library Reference in VBA”.
  4. Next, copy the VBA code below into an empty module.
Sub ReplaceSpecificTextWithSpecificImage()
    Dim objMail As Outlook.MailItem
    Dim objMailDocument As Word.Document
    Dim objWordApp As Word.Application
    Dim strText As String
    Dim strImageFile As String
    On Error Resume Next
    Set objMail = Outlook.Application.ActiveInspector.CurrentItem
    Set objMailDocument = objMail.GetInspector.WordEditor
    Set objWordApp = objMailDocument.Application
    'Change the specific text and the image file path
    strText = "DataNumen, Inc."
    strImageFile = "E:\DataNumen Products\Logo(thumbnail).jpg"
    With objWordApp.Selection
         .HomeKey Unit:=wdStory

       With .Find
           .Text = strText
        Do While .Execute
            objWordApp.Selection.InlineShapes.AddPicture FileName:=strImageFile, LinkToFile:=False, SaveWithDocument:=True
         .Replacement.Text = ""
         .Wrap = wdFindContinue
         .Execute Replace:=wdReplaceAll
       End With
    End With
End Sub

VBA Code - Replace All Occurrences of a Specific Text with an Image

  1. Ultimately, press “F5” key button to run this macro.
  2. After macro completes, close the editor window.
  3. Now, you can check the source email, in which the occurrences of the specific text must have been replaced with the specific picture.

Don’t Look Down Upon Small Errors in Outlook

Maybe you have been subject to diverse Outlook issues. To be honest, it is almost impossible to predict errors in Outlook effectively. At best, small errors can be solved by a simple restart. Yet, if the troubles are much more complex than what you think, leaving them aside will keep your Outlook file in danger. Therefore, it’s suggested to eliminate the errors as soon as possible. Thus, you’d better get hold of a potent and reliable PST fix tool, such as DataNumen Outlook Repair. It is able to fix PST issues in a jiffy.

Author Introduction:

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

Leave a Reply

Your email address will not be published.