#1   Report Post  
Posted to microsoft.public.word.docmanagement
jatman jatman is offline
external usenet poster
 
Posts: 12
Default word email macro

I'm back once again. i am working on a macro to send a word document as an
attachment. this is where i am so far:

file is created, saved as a docx file (Office 2007 on Vista), now i want to
email the file out to several recipients, in the array as follows:

Dim Recip As Variant
Recip = ")
.SendMail

the file attached is correct and the subject line is the same as the file
name, so all of that is ok. at this point, the outlook dialog box opens up
and just sits there. it does not accept the recipient's email address. i
have tried the same portion of a macro from an excel file and i get an error
in word, but works fine in excel.

i have also checked http://word.mvps.org/FAQs/InterDev/SendMail.htm and
tried the routing slip method (smaller and clean macro,) but i got an error
5892 on that also.

any other suggestions to make this work?

jat

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default word email macro

How about:

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

Recip(0) = "
Recip(1) = "
Recip(2) = "

On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then 'Document has not been saved
ActiveDocument.Save 'so save it
End If
'see if Outlook is running and if so turn your attention there
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err 0 Then 'Outlook isn't running
'So fire it up
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Open a new e-mail message
For i = 0 To 2
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem 'and add the detail to it
.To = Recip(i) 'send to this address
.Subject = "New subject" 'This is the message subject
.Body = "See attached document" ' This is the message body text
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
.Send
End With
Next i
If bStarted Then 'If the macro started Outlook, stop it again.
oOutlookApp.Quit
End If
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



jatman wrote:
I'm back once again. i am working on a macro to send a word document
as an attachment. this is where i am so far:

file is created, saved as a docx file (Office 2007 on Vista), now i
want to email the file out to several recipients, in the array as
follows:

Dim Recip As Variant
Recip = ")
.SendMail

the file attached is correct and the subject line is the same as the
file name, so all of that is ok. at this point, the outlook dialog
box opens up and just sits there. it does not accept the recipient's
email address. i have tried the same portion of a macro from an
excel file and i get an error in word, but works fine in excel.

i have also checked http://word.mvps.org/FAQs/InterDev/SendMail.htm
and tried the routing slip method (smaller and clean macro,) but i
got an error 5892 on that also.

any other suggestions to make this work?

jat



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Email word doc as attachment using a macro? lizb789 Microsoft Word Help 2 March 19th 08 08:56 PM
using a macro so send an email Shazza Microsoft Word Help 6 July 18th 07 04:08 PM
Sending a WORD doc via email via a MACRO Matt Microsoft Word Help 1 March 21st 07 12:50 PM
Create macro to write email address in email window albycindy Microsoft Word Help 3 August 22nd 05 07:57 PM
Email macro that changes the file name Mike Anderson Microsoft Word Help 0 July 13th 05 03:57 AM


All times are GMT +1. The time now is 02:18 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"