How to Extract & Show All Hyperlink Addresses in an Email via Outlook VBA

Most of time, to view the hyperlink addresses, you need to hover the cursor over the displaying text. This article will teach you to use VBA to show all the addresses in one email simply by one click.

As you know, apart from directly adding a URL in the email body, you’re allowed to insert hyperlink to texts. In this case, you will be unable to view the hyperlink addresses straightly. You need to hover the cursor over the displaying text. But, it will be quite tedious if there are too many such hyperlinks in the current email as you have to check the addresses one by one.

Extract & Show All Hyperlink Addresses in an Email via Outlook VBA

In response to this issue, here we will expose a quick method which is using VBA to help you extract and display all the hyperlink addresses directly. By this way, what you are required to do is simply one click. Now read on to get the elaborate steps and VBA code.

Extract & Show All Hyperlink Addresses in an Email

  1. In the first place, launch your Outlook application.
  2. Then press “Alt + F11” key buttons in the main Outlook window.
  3. Next you will get access to Outlook VBA editor successfully.
  4. Subsequently, you will be required to open a module which is not in use.
  5. After that, copy and paste the following VBA codes into this module.
Sub ShowAllHyperlinkAddresses()
    Dim objMail As Outlook.MailItem
    Dim objWordDocument As Word.Document
    Dim objWordApp As Word.Application
    Dim objWordSelection As Word.Selection
    Dim objHyperlinks As Word.Hyperlinks
    Dim objHyperlink As Word.Hyperlink
    Dim strLink As String
 
    Set objMail = Outlook.Application.ActiveInspector.CurrentItem
    Set objWordDocument = objMail.GetInspector.WordEditor
    Set objWordApp = objWordDocument.Application
    Set objHyperlinks = objWordDocument.Hyperlinks
 
    If objHyperlinks.Count > 0 Then
       For Each objHyperlink In objHyperlinks
           strLink = objHyperlink.Address
           strLink = vbTab & "<" & strLink & ">"
           objHyperlink.Range.InsertAfter strLink
           objHyperlink.Delete
           With objWordApp.Options
                .AutoFormatReplaceHyperlinks = True
                .AutoFormatApplyOtherParas = False
                .AutoFormatApplyHeadings = False
                .AutoFormatApplyBulletedLists = False
                .AutoFormatApplyLists = False
                .AutoFormatApplyFirstIndents = False
          End With
          Set objWordSelection = objWordApp.Selection
          objWordSelection.Range.AutoFormat
       Next
    End If
End Sub

VBA Code - Extract & Show All Hyperlink Addresses in an Email

  1. Later, for later convenience, you had better add the new macro to the Quick Access Toolbar of message window.
  2. Also, you ought to ensure that your Outlook macro settings permit macros.
  3. Finally you can have a try.
  • First, open an email which contains many hyperlinks.
  • Then switch to the editable mode. Just click “Actions” > “Edit Message”.
  • Next click the macro button in the Quick Access Toolbar.
  • At once, all the hyperlink addresses will be extracted and displayed like the following screenshot:Show Hyperlink Addresses

Not Immune from Outlook Problems

Although Outlook provides users with a lot of flexible functions, it still cannot get exempt from errors and crashes. Therefore, if you wish to safeguard your Outlook data against corruption or loss, you have to make great efforts. For instance, you need to persist in making Outlook data backups regularly. Of course, it’ll be much better if you prepare a potent Outlook recovery tool, 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 corrupted sql and outlook repair software products. For more information visit www.datanumen.com

Comments are closed.