PDA

View Full Version : Convert Hyperlink Address Property to Text



BAlGaInTl
05-08-2019, 06:12 AM
Hello,

I don't normally venture in to Outlook programming, but I have a problem I'm trying to solve. My organization recently enabled ATP for incoming outlook email links from external sources. So now, when I reply to an email, identifying information remains in place in a "Safe Link" from Microsoft.

Not a huge deal, but it bugs me.

So I found the following code that successfully replaces the Address property of hyperlinks:


Sub HyperLinkChange()Dim objDoc As Object
Dim tmpLink As Object
On Error Resume Next
If ActiveInspector.EditorType = olEditorWord Then
' use WordEditor Inspector
Set objDoc = ActiveInspector.WordEditor
For Each tmpLink In objDoc.Hyperlinks
tmpLink.Address = "Hyper Link Removed. Please copy and paste into your browser to view"
Next tmpLink
End If
End Sub

I wanted to expand on this, and only run the code to replace if it's actually an ATP Safe Link.

I found that if I use something like


response = msgbox(tmpLink.Address)

a dialog box is presented with the link. But if I try to evaluate tmpLink.Address as a string, it's just blank.

Is there a way to convert tmpLink.Address in this situation to a string that can be evaluated?

ETA:

I cross-posted this over to the MrExcel forums since that's normally where I've been active. If that's against any rules, please feel free to delete.

https://www.mrexcel.com/forum/general-excel-discussion-other-questions/1096985-outlook-vba-change-replace-hyperlinks-before-sending.html