ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   E-mailing from Excel 2003 problem (https://www.excelbanter.com/excel-programming/350559-e-mailing-excel-2003-problem.html)

PaulC

E-mailing from Excel 2003 problem
 

I am running the following macro from Excel (2003) to send an e-mail
from Outlook. When the e-mail has gone I want to be returned to Excel.
This worked fine in Excel 97, but with Excel 2003, Outlook always
remains on top at the end. What do I need to add to bring Excel backto
the front? (The YesClickmacros work okay.)

Paul


Sub SendEmailFromExcel()

Dim oOut1 As New Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oMail As Outlook.MailItem

Set oNS = oOut1.GetNamespace("MAPI")
oNS.Logon
Set oMail = oOut1.CreateItem(olMailItem)

ResumeYesClickMacro

With oMail
..Subject = "Changes to Client Details....."
..Recipients.Add "
..Send
End With

oNS.Logoff
Set oNS = Nothing

SuspendYesClickMacro

End Sub


--
PaulC
------------------------------------------------------------------------
PaulC's Profile: http://www.excelforum.com/member.php...fo&userid=7563
View this thread: http://www.excelforum.com/showthread...hreadid=501741



All times are GMT +1. The time now is 12:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com