Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Hyperlink In Email From Word Document

Status
Not open for further replies.

LCJ18786

Programmer
Nov 23, 2011
9
GB
I need to achieve selecting a button from MS Word and then getting a hyperlink in a email with the full UNC path to a document saved on the server.

I so far have achieved selecting a button within MS Word which captures the UNC network path name and document name and stores the full location in a variable.

I have got Outlook to open but whilst using the .HTMLBody text I can't seem to find a way for Outlook to insert the a hyperlink using my stored variable.

I found this line of code and modified it with my code and this didnt work -
.HTMLBody = "<a href=file://" & myAddFileName & ">" & myAddFileName & "</a>"


myAddFileName is the variable I need to use. Could somebody please tell me how I can get this to work using the .HTMLbody property?


Please see a snipet of the code below -


'Creates the e-mail
Set MyMail = MyOutlook.CreateItem(olMailItem)

With MyMail
'Set the properties for the email
.To = ""
.Subject = ""
.HTMLBody = myAddFileName
End With
 
This is what I do in a sub to create a hyper link. the path get the string that goes to your document and update the .xlsx to the correct type of documnet. Then repeat the string again.

This string will show up in Arial <font face=Arial>

about 10 point font <font size=3>

and in bold <b> and italics <i>


str_link = "<b> <font face=Arial> <font size=3> <i> <a href=""\\your path here.xlsx"">\\your path here.xlsx" & "</Font></a></b></i>"


Ebody = "This link " & str_link & " is the link I want."

Then change your code to include this

.HTMLBody = Ebody
.Display

That should work for you.
 
By the way, your code only will show myAddFileName because .HTML body is being declared as myAddFileName.
 
Thanks.

I still have a problem as the link isn't actually being displayed as a hyperlink in the email to a document on our server.

Any other ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top