creating link to automatically email a word doc

  • Thread starter Thread starter Kookaburra16
  • Start date Start date
K

Kookaburra16

I am trying to find out if I can create an automatic link (?hyperlink) that
when someone finishes filling out a survey I have created in word it will
email the document as an attachment back to me by clicking the link. Can
anyone help??
 
If your users have Outlook, then you could run a macro, stored in the
document, similar to the following from a toolbar button. This sends the
current document as attachment to the e-mail address entered without further
prompting. Chances are that it wouldn't work as many users will sensibly
block macros in third party documents, so it wouldn't run. The problem with
a hyperlink will be in *automatically* attaching the document to the
hyperlinked mail dialog. I may be wrong, but I don't think that is possible.

Sub SendDocumentAsAttachment()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
ActiveDocument.Save
End If

Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
.To = "(e-mail address removed)"
.Subject = "New subject"
.Body = "See attached document"
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
.Send
End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub

http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top