Hello,
I have written the following code to create a message with two hyperlinks embedded and then copy that message to the clipboard. I am getting a Run-time error saying "Automation Error" and "Unspecified error" when executing the .hyperlinks line of code. Any help would be tremendously appreciated.
I have written the following code to create a message with two hyperlinks embedded and then copy that message to the clipboard. I am getting a Run-time error saying "Automation Error" and "Unspecified error" when executing the .hyperlinks line of code. Any help would be tremendously appreciated.
Code:
Sub ES_Message2()
'Dimension variables
Dim ArticleOneURL As Range
Dim ArticleTwoURL As Range
'Assign hyperlinks
With ActiveSheet
.Hyperlinks.Add Anchor:=ArticleOneURL, Address:="https://docs.microsoft.com/en-us/office/vba/api/excel.hyperlinks.add", TextToDisplay:="see here"
End With
With ActiveSheet
.Hyperlinks.Add Anchor:=ArticleTwoURL, Address:="https://docs.microsoft.com/en-us/office/vba/api/excel.hyperlinks.add", TextToDisplay:="see here"
End With
'Create Message
EmailMessage = "Hi Customer, please follow the follow our article on topic 1 (" & ArticleOneURL & ") and topic 2 (" & ArticleTwoURL & ")."
'Copy message to clipboard
With New MSForms.DataObject
.SetText EmailMessage
.PutInClipboard
End With
End Sub