Inserting a hyperlink to a file using Word VBA

E

enizag

HI

I am having difficulty acheiving this.
I have a word document which a user fills in, once complete the press a
button, the form is saved and then I want the file path and filename to
be embedded into the body of an email automatically, so the next person
receives the email with a hyperlink to the specific form.
I have tried numerous approaches, this one will put a hyperlink in the
email but when I click it, it can't find the file:
<a href=file://" & szEmailTemp & ">click
me</a></FONT></DIV>
I have used REPLACE to convert the spaces into %20, but still no luck.
I can't get the hyperlink to find the file I want, although it is
there.
I send the email using the following:

Code:
--------------------
Set smApp = CreateObject("outlook.application")
Set smMail = CreateObject("SecureEmail.SafeMailItem")
Set smItem = smApp.CreateItem(0)
Set myAttachments = smMail.Attachments
--------------------


Code:
--------------------
addFileName = "\\Nas080501\colleague\Shared Files\report requests\Requested reports\" & fName '& ".doc"
addFileName = Replace(addFileName, " ", "%20")
--------------------


Code:
--------------------
With smMail
.HTMLBody = szEmailBody
.Subject = emailSubject
.ReadReceiptRequested = True
.Recipients.Add returnEmail
.Recipients.ResolveAll
.Send
End With

--------------------


Any help will be greatly appreciated.

Cheers :)
 
M

Michael Bauer [MVP - Outlook]

This works, please see the ' character the path is embedded in:

htmlbody="<a href='file://\\server\test\test.doc'>click</a>"

Of course, the path must be valid for the user.

Next time, please use microsoft.public.outlook.program_vba for programming
related questions.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Wed, 9 Dec 2009 11:48:59 -0500 schrieb enizag:
HI

I am having difficulty acheiving this.
I have a word document which a user fills in, once complete the press a
button, the form is saved and then I want the file path and filename to
be embedded into the body of an email automatically, so the next person
receives the email with a hyperlink to the specific form.
I have tried numerous approaches, this one will put a hyperlink in the
email but when I click it, it can't find the file:
<a href=file://" & szEmailTemp & ">click
me</a></FONT></DIV>
I have used REPLACE to convert the spaces into %20, but still no luck.
I can't get the hyperlink to find the file I want, although it is
there.
I send the email using the following:

Code:
--------------------
Set smApp = CreateObject("outlook.application")
Set smMail = CreateObject("SecureEmail.SafeMailItem")
Set smItem = smApp.CreateItem(0)
Set myAttachments = smMail.Attachments
requests\Requested reports\" & fName '& ".doc"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top