Consulting

Results 1 to 4 of 4

Thread: Outlook 2003 - Help Required for Hyperlinks

  1. #1
    VBAX Regular
    Joined
    Aug 2014
    Posts
    7
    Location

    Outlook 2003 - Help Required for Hyperlinks

    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

  2. #2
    what is the hyperlink to (href) and how is it added?

  3. #3
    VBAX Regular
    Joined
    Aug 2014
    Posts
    7
    Location
    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

  4. #4
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    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
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •