Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 49888

Need help witl Hyperlink in Email body

$
0
0
Hello everyone,

I'm having an issue with the hyperlink I'm trying to make.

The hyperlink is contained in an email created by the macro. The hyper link needs to refer to a file name provided in cell E3.

I'm having two issues.

1. The hyperlink is not registering spaces and stops at the first space therefore the file path is not complete (it should be R:\DESIGN\DESIGN TEMPLATE\Special Purchase Request\ but actually it comes out as R:\DESIGN\DESIGN)

2. How do I refer to the cell to get the filename?

Code:

Sub Print_and_Email()
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
'Working in Office 2000-2013
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

        strbody = "Hi Rory,<br></br>" & _
              "<br>A new Special Purchase Request form has been saved in the folder.</br>" & _
              "<br></br><br></br>Please can you provide a quotation for the items listed." & _
              "<br></br><br></br><A HREF=file:\\R:\DESIGN\DESIGN TEMPLATE\Special Purchase Request\ & filename>Special Purchase Request link</A>" & _
              "<br></br><br></br>Thank you" & _
              "<br></br><br></br>" & Range("C2").Value


    On Error Resume Next
    With OutMail
        .To = ""
        .CC = ""
        .BCC = ""
        .Subject = "Special Purchase Request - " & Range("E2").Value
        .HTMLBody = strbody & "<br>" & .HTMLBody
        'You can add a file like this
        '.Attachments.Add ("C:\test.txt")
        .Send  'or use .Display
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
   
' SavePDF Macro
'Sheets("Request Form").Select
'ChDir "L:\"
'ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Range("Data!E1").Value _
', Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
':=False, OpenAfterPublish:=True
'Sheets("Data").Select

End Sub


Viewing all articles
Browse latest Browse all 49888

Trending Articles