PDA

View Full Version : Outlook 2003 - Help Required for Hyperlinks



Emmerly
08-23-2014, 08:27 AM
Hi,

I'm working on quite a big project and I have come slightly unstuck at the smallest thing, I'm sure it's a really easy one.

As a bit of background to this I send out emails to certain people and wanted them to confirm that the email has been actioned, to do this I've made a hyperlink at the end of an email that they then click on and send back. Most of these users are OWA so I couldn't get voting buttons or tasks to work for them, these responses then go into an outlook folder and then get put into an excel spreadsheet. I've then got a few formulas setup to keep track of who has replied and who hasn't. I want other people to be able to add this hyperlink at the bottom of their emails so my spreadsheet can do the same thing for them. I was going to create a quick macro for them to run the hyperlink, the issue I'm having with this is that I need the email subject to be different on each email sent out otherwise it will confuse the excel spreadsheet. My thoughts were for the macro for the hyperlink to grab the current subject line but I haven't figured out how to write this? Is this something you can help me with?

Thanks for reading this :)

westconn1
08-23-2014, 04:06 PM
what is the hyperlink to (href) and how is it added?

Emmerly
08-27-2014, 01:57 AM
This is the VBA as it stands:


Sub HyperLink()

'
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"mailto:Email Address?subject=This is where I would like the email subject to be picked up", SubAddress:="", ScreenTip:="" _
, TextToDisplay:="Please confirm here once email has been actioned"
End Sub

skatonni
09-11-2014, 12:57 PM
Try this


Private Sub HyperlinkMailtoWithDynamicSubject()

Dim objOL As Outlook.Application
Dim objNS As Outlook.Namespace

Dim objDoc As Word.Document
Dim objSel As Word.Selection

Dim currItem As mailitem
Dim MailtoSubject As String
Dim strHyperlinkAddress As String

Set objOL = Application

Set currItem = objOL.ActiveInspector.CurrentItem
MailtoSubject = currItem.subject

If objOL.ActiveInspector.EditorType = olEditorWord Then

Set objDoc = objOL.ActiveInspector.WordEditor
Set objNS = objOL.Session
Set objSel = objDoc.Windows(1).Selection

strHyperlinkAddress = "mailto:someone@somewhere.com?subject=" & MailtoSubject

objSel.Hyperlinks.Add Anchor:=objSel.Range, Address:=strHyperlinkAddress, _
TextToDisplay:="Please confirm here once email has been actioned"

End If

Set objOL = Nothing
Set objNS = Nothing
Set currItem = Nothing

Set objDoc = Nothing
Set objSel = Nothing

End Sub