Template With Send Request

C

Carol

How do I insert a send button within a document that I have saved as a
template? I am trying to create a template that people can send to a global
email address to request certain documents and I want a button within the
document that can be clicked on to send their request to me via email.
 
D

Doug Robbins - Word MVP

The following code in a macro can be used the send the active document as
the body of an email message IF the sender is using Microsoft Outlook. It
will require that in your template, you set a reference via Tools>References
in the Visual Basic Editor to the Microsoft Outlook #.0 Object Library.

Dim source As Document
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

Set source = ActiveDocument

' Check if Outlook is running. If it is not, start Outlook
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
'oOutlookApp.DefaultProfileName
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

source.Sections(j).Range.Copy
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.Subject = "Document Request"
.BodyFormat = olFormatHTML
.Display
Set objDoc = .GetInspector.WordEditor
Set objSel = objDoc.Windows(1).Selection
objSel.Paste
.To = "(e-mail address removed)"
.cc = "(e-mail address removed)"
.Send
End With
Set oItem = Nothing

' Close Outlook if it was started by this macro.
If bStarted Then
oOutlookApp.Quit
End If

MsgBox source.Sections.Count - 1 & " messages have been sent."

'Clean up
Set oOutlookApp = Nothing

You could call the macro by the use of a macrobutton on the document

See the article "Using MacroButton fields†at:
http://www.word.mvps.org/FAQs/TblsFldsFms/UsingMacroButton.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
C

Carol

Thanks Doug. I am not familiar with Macros so that was a bit over my head.
I am using Outlook as my email already. I am also using Word 2003. Do you
happen to know of a more simple way of telling me how to do this?
 
G

Graham Mayor

Had there been a simpler way Doug would have mentioned it - see
http://www.gmayor.com/installing_macro.htm for a guide on what to do with
the macro code.

There is a proviso with this method and that concerns the people who would
be using the template. If they don't have access to Outlook a macro that
accesses Outlook is not going to help. Without knowing what e-mail
application the users will have, it is difficult to provide a function to
access it - if indeed the e-mail application is programmable from Word.

There is a similar macr on my web site at
http://www.gmayor.com/word_vba_examples.htm under the heading "Send the
current document from Word by e-mail as an attachment, with the header
details pre-completed, e.g. for the return of a completed form document."
which is annotated to help demonstrate how it works.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Carol

All users are using Outlook.

Graham Mayor said:
Had there been a simpler way Doug would have mentioned it - see
http://www.gmayor.com/installing_macro.htm for a guide on what to do with
the macro code.

There is a proviso with this method and that concerns the people who would
be using the template. If they don't have access to Outlook a macro that
accesses Outlook is not going to help. Without knowing what e-mail
application the users will have, it is difficult to provide a function to
access it - if indeed the e-mail application is programmable from Word.

There is a similar macr on my web site at
http://www.gmayor.com/word_vba_examples.htm under the heading "Send the
current document from Word by e-mail as an attachment, with the header
details pre-completed, e.g. for the return of a completed form document."
which is annotated to help demonstrate how it works.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

That makes things a bit simpler - add Doug's (or my) version of the macro to
a toolbar button.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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