Sending Email from Word 2007

R

Rob W

Greetings,

I am wanting to send a questionnaire via word (It must keep its formatting
as is full of list box and other controls), so I recorded the macro of using
the word 2007 option to send email

ActiveDocument.SendMail

I then want to add a subject, recipients and even a message would be a nice
bonus! Which I dont think is supported via .SendMail

I googl'd around and found

http://word.mvps.org/FAQs/InterDev/SendMail.htm

The first method roundslip doesnt appear to work as error appears ..

Run-time error '5892';
Method 'HasRoutingSlip' of object '_Document' failed.

The second method cant be applied due to the formattign issue, plus Im sure
it could be done simpler.

Any advice or assistance would be appreciated.

Cheers
Rob W
 
R

Rob W

I should also add Outlook Express is my DEFAULT emailer.

Seems this causes issues with objMailItem

Cheers
Rob
 
R

Rob W

I found some example code on the web, however the message "user defined type
not define appears on line "oOutlookApp As Outlook.Application"

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

On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
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"
'Add the document as an attachment, you can use the .displayname
property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
DisplayName:="Document as attachment"
.Send
End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing
 
G

Graham Mayor

See the reply in vba beginners - and please do not multi-post.

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


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

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