Inserting Hyperlink to Local File in Outlook Email
Posted on 2005-04-20
I have written a macro in Word (see end of this message) which creates a message that I paste into an Outlook email. The message contains the name of a file that I want my secretary to proofread. I run it when I have the file in question open in Word, then close the document. If the file name (or its path) has no spaces in it, I get a click-able link to the file, but if there are any spaces, the link is broken at the first space.
Q. -- How could I modify the macro so that what I get to paste into the Outlook email will create a clickable link to the file -- even if the file name (or path) contains spaces?
You can manually make a hyperlink in Outlook using the "Tools, Insert Hyperlink" command. And the actual html code that is inserted will be like this:
<A href="file://Bambam/Clients/Letter to My Client.Doc">file://Bambam/Clients/Letter to My Client.Doc</A>
although once inserted will look like:
file://Bambam/Clients/Letter to My Client.Doc
However, if you just manually insert the same code into the body of the email, you don't get a functional hyperlink. You just get the raw code.
If ActiveDocument.FullName = "" Then GoTo nameit
Dim currname As String
currname = "Please open " + Chr$(13) + Chr$(10) + Chr$(13) + Chr$(10) + ActiveDocument.FullName + Chr$(13) + Chr$(10) + Chr$(13) + Chr$(10) + "and review it, making any corrections you think appropriate, then print for my signature."
Dim mydata As Object
Set mydata = New DataObject
MsgBox ("This document has not been named or saved")