Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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 | |
|
|
![]() |
||||
Thread | Forum | |||
Email word doc as attachment using a macro? | Microsoft Word Help | |||
using a macro so send an email | Microsoft Word Help | |||
Sending a WORD doc via email via a MACRO | Microsoft Word Help | |||
Create macro to write email address in email window | Microsoft Word Help | |||
Email macro that changes the file name | Microsoft Word Help |