+ Reply to Thread
Results 1 to 4 of 4

VBA to follow PDF hyperlink and attch to email

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    VBA to follow PDF hyperlink and attch to email

    Hello,
    The code below follows a hyperlink and attaches it to an email, problem is that if the hyperlink is a PDF file it won't attach the PDF but instead the active excel workbook which is the file that has the hyperlink!
    Sub Email()
    '
    '
    Dim wb2 As WorkBook
    With OutMail
    .To = EMAIL & ";" & CC & ";"
    .CC = ""
    .BCC = ""
    .Subject = Brand & " #" & ws.Range("G9").Value
    If HasHyperlink(ws.Range("D24")) Then
    ws.Range("D24").Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
    Set wb2 = ActiveWorkbook
    Windows(MainWb).Activate
    .Attachments.Add wb2.FullName
    End If
    End Sub
    Thanks in advance!
    Last edited by kosherboy; 01-18-2016 at 05:36 PM.

  2. #2
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: VBA to follow PDF hyperlink and attch to email

    What's in D24? Whats the hyperlink?
    Frob first, tweak later

  3. #3
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: VBA to follow PDF hyperlink and attch to email

    Hi Neil,
    It's a hyperlink to a pdf file.

  4. #4
    Valued Forum Contributor
    Join Date
    11-27-2013
    Location
    Brooklyn, NY
    MS-Off Ver
    Office 365
    Posts
    1,172

    Re: VBA to follow PDF hyperlink and attch to email

    Took me a couple hours but i finally figured out the answer:
                On Error Resume Next
                If Range("A1").Hyperlinks.Count > 0 Then
                    fpath = Range("A1").Hyperlinks.Item(1).Address
                End If
                .Attachments.Add (fpath)
    Problem solved!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Follow a Bloomberg Hyperlink
    By jsuarez199 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-16-2015, 12:15 PM
  2. hyperlink to follow other hyperlink
    By MarcoAUA in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2012, 11:30 PM
  3. Follow hyperlink and read only
    By psychoPETE in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-16-2010, 07:34 PM
  4. Follow hyperlink
    By nazimscr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-10-2009, 03:56 AM
  5. Help with Follow Hyperlink VB Statement
    By Ben Matthews in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-08-2009, 12:09 PM
  6. [SOLVED] follow hyperlink?
    By JethroUK© in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-05-2006, 04:55 PM
  7. follow hyperlink?
    By JethroUK© in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-05-2006, 04:55 PM
  8. follow hyperlink?
    By JethroUK© in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 04-05-2006, 04:55 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1