GrayStrickland
asked on
Using VBA to insert hyperlink to local file in outlook email
I've written a VBA macro for MS Word to create an email in Outlook. It's supposed to create a hyperlink in the body of the email, but does not. The relevant portion of the code is at the end of this email. The macro grabs the full path & file name of the current file and stores it as a variable (currname) with all the spaces replaced with "%20". If I paste that variable in an email AND THEN SPACE WITH THE SPACEBAR, it creates a hyperlink which you can click on. The macro inserts the text, but it doesn't trigger outlook to turn it into a hyperlink.
Q. -- what can I do to make sure that a hyperlink is created?
I'm trying to automate a work-flow system for a small workgroup where critical documents are proofread by a co-worker before release. The intent of the macro is to automate sending an email which contains a hyperlink that the coworker can click on to open the document. We don't want to email the actual document around.
========================== ========== ====
Dim currname As String
currname = Replace(ActiveDocument.Ful lName, " ", "%20")
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
Set mydata = New DataObject
Set oOutlookApp = GetObject(, "Outlook.Application")
Set oItem = oOutlookApp.CreateItem(olM ailItem)
With oItem
.BodyFormat = olFormatHTML 'Set the recipient for the new email
.To = "somebody@myfirm.com"
.Subject = "PROOFREAD"
.Body = "Please click this link " & currname & " to open this document. Please proofread it and correct any errors, then print and bring to me for signature."
.Display
End With
Q. -- what can I do to make sure that a hyperlink is created?
I'm trying to automate a work-flow system for a small workgroup where critical documents are proofread by a co-worker before release. The intent of the macro is to automate sending an email which contains a hyperlink that the coworker can click on to open the document. We don't want to email the actual document around.
==========================
Dim currname As String
currname = Replace(ActiveDocument.Ful
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
Set mydata = New DataObject
Set oOutlookApp = GetObject(, "Outlook.Application")
Set oItem = oOutlookApp.CreateItem(olM
With oItem
.BodyFormat = olFormatHTML 'Set the recipient for the new email
.To = "somebody@myfirm.com"
.Subject = "PROOFREAD"
.Body = "Please click this link " & currname & " to open this document. Please proofread it and correct any errors, then print and bring to me for signature."
.Display
End With
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.