Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-05-2013, 09:31 AM
AnneN AnneN is offline Macro to send document in email Windows 7 32bit Macro to send document in email Office 2010 32bit
Novice
Macro to send document in email
 
Join Date: Feb 2013
Posts: 1
AnneN is on a distinguished road
Default Macro to send document in email

I'm trying to write a Macro that takes a Word 2010 document and sends it in the body of an email to a set email distribution list by clicking a button on the document. I had everything working but only when I run the Macro on my computer and this will be a report that several people will fill out and will need to email. Then I upgraded to Office 2010 and now it won't even work on my PC.



Any help is appreciated!

Here is my current code:

Code:
 
Sub SendDocumentInMail()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
'Get Outlook if it's running
 Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
    'Outlook wasn't running, start it from code
    Set oOutlookApp = CreateObject("Outlook.Application")
     bStarted = True
 End If
'Create a new mailitem
 Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
     'Set the recipient for the new email
   .To = "IDS-Omaha-LeadNurseReport@xxxxx.com"
     'Set the recipient for a copy
    .Subject = "Lead Nurse Report"
     'The content of the document is used as the body for the email
    .Body = ActiveDocument.Content
     .Send
 End With
If bStarted Then
     'If we started Outlook from code, then close it
    oOutlookApp.Quit
End If
'Clean up
 Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
Reply With Quote
  #2  
Old 02-05-2013, 08:08 PM
macropod's Avatar
macropod macropod is offline Macro to send document in email Windows 7 64bit Macro to send document in email Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi AnneN,

Do you get an error message? If so, what does it say and what code line, if any, gets highlighted?

Your macro uses early binding. Have you set a reference in Word's vbe to the Microsoft Outlook Object Library?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to export email to text file on send depending on category Joe Patrick Outlook 0 10-19-2012 06:20 PM
Macro to send document in email Send e-mail by macro plamenbv Excel Programming 1 04-16-2012 05:25 AM
Macro to send document in email How to send an email to all contacts I ever send an email to? JSYdeJong Outlook 1 11-02-2011 07:22 PM
Send document as email pat-ty Word 0 09-09-2010 10:23 AM
Macro to send document in email Can't send email helpplease Outlook 6 12-21-2008 06:00 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:03 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft