View Single Post
  #10  
Old January 6th 09, 05:28 PM posted to microsoft.public.outlook.program_vba
JP[_3_]
external usenet poster
 
Posts: 201
Default Can I disable Outlook warning from Excel macro "Send" method

Nice job! You might also want to call the Quit Method on the Excel
Application Object, to make sure that instance of Excel is destroyed.
Just setting the reference to Nothing may not be enough.

HTH


On Jan 5, 5:11*pm, wpiet wrote:
Ken & JP,

Thanks to both of you, everything works beautifully.

For the benefit of others looking for such a solution, here's the relevant
code from my Outlook macro that creates e-mails from an Excel workbook:

*(sheet 'E-Mail' has 2 columns; 'A' = e-mail addresses; 'B' = text of
messages)

Sub MacroName()
* * Dim XL * * * * *As Object
* * Dim WB * * * * As Workbook
* * Dim Cell * * * *As Range
* * Dim EmlMsg *As MailItem

' Open Excel & workbook

* * Set XL = CreateObject("Excel.Application")
* * XL.Visible = True
* * Set WB = GetObject("\\Server\Folder\Master.xls")
* * XL.Windows("Master.xls").Visible = True

' Send e-mails

* * For Each Cell In XL.Sheets("E-Mail").Columns("B").Cells
* * * * If Cell.Value = "" Then
* * * * * * Exit For
* * * * Else
* * * * * * Set EmlMsg = CreateItem(0)

* * * * * * With EmlMsg
* * * * * * * * .To * * * *= Cell.Offset(0, -1)
* * * * * * * * .Subject = "Your Subject Here"
* * * * * * * * .Body * * = Cell.Value
* * * * * * * * .Send
* * * * * * End With

* * * * * * Set EmlMsg = Nothing
* * * * End If
* * Next Cell

' Release workbook & Excel application

* * Set WB = Nothing
* * Set XL = Nothing
End Sub
--
Will

Ads