Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
CreateObject("Outlook.Application")
Hi,
I have procedure for sending mail. The problem is that the procedure will work the first time it is executed but not the second time then the third time it will work but not the fourth time and so on. The sendEmail procedure is below. Any help will be very much appreciated! Public Sub sendMail() On Error Resume Next Dim oLApp As Object Dim eMail As Object Dim thisWb As String thisWb = ThisWorkbook.Path & "\" & ThisWorkbook.Name Set oLApp = CreateObject("Outlook.Application") Set eMail = oLApp.CreateItem(olMailItem) With eMail .To = " .Subject = "some subject" .Attachments.Add (thisWb) .Display End With Set eMail = Nothing Set oLApp = Nothing End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
CreateObject("Outlook.Application")
Try this
Set olApp = Nothing On Error Resume Next Set olApp = GetObject(, "Outlook.Application") On Error GoTo 0 If olApp Is Nothing Then Set olApp = CreateObject("Outlook.Application") End If I'm betting that the first time you run it, Outlook is not open and the second time it is. -- HTH, Barb Reinhardt "Howard31" wrote: Hi, I have procedure for sending mail. The problem is that the procedure will work the first time it is executed but not the second time then the third time it will work but not the fourth time and so on. The sendEmail procedure is below. Any help will be very much appreciated! Public Sub sendMail() On Error Resume Next Dim oLApp As Object Dim eMail As Object Dim thisWb As String thisWb = ThisWorkbook.Path & "\" & ThisWorkbook.Name Set oLApp = CreateObject("Outlook.Application") Set eMail = oLApp.CreateItem(olMailItem) With eMail .To = " .Subject = "some subject" .Attachments.Add (thisWb) .Display End With Set eMail = Nothing Set oLApp = Nothing End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
CreateObject("Outlook.Application")
FWIW, you can replace
thisWb = ThisWorkbook.Path & "\" & ThisWorkbook.Name with thisWS = Thisworkbook.fullname -- HTH, Barb Reinhardt "Howard31" wrote: Hi, I have procedure for sending mail. The problem is that the procedure will work the first time it is executed but not the second time then the third time it will work but not the fourth time and so on. The sendEmail procedure is below. Any help will be very much appreciated! Public Sub sendMail() On Error Resume Next Dim oLApp As Object Dim eMail As Object Dim thisWb As String thisWb = ThisWorkbook.Path & "\" & ThisWorkbook.Name Set oLApp = CreateObject("Outlook.Application") Set eMail = oLApp.CreateItem(olMailItem) With eMail .To = " .Subject = "some subject" .Attachments.Add (thisWb) .Display End With Set eMail = Nothing Set oLApp = Nothing End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
CreateObject("Outlook.Application")
Thanks Barb Reinhardt! I'll try it out. By the way is "Thisworkbook.fullname"
availble in xl2003? "Barb Reinhardt" wrote: FWIW, you can replace thisWb = ThisWorkbook.Path & "\" & ThisWorkbook.Name with thisWS = Thisworkbook.fullname -- HTH, Barb Reinhardt "Howard31" wrote: Hi, I have procedure for sending mail. The problem is that the procedure will work the first time it is executed but not the second time then the third time it will work but not the fourth time and so on. The sendEmail procedure is below. Any help will be very much appreciated! Public Sub sendMail() On Error Resume Next Dim oLApp As Object Dim eMail As Object Dim thisWb As String thisWb = ThisWorkbook.Path & "\" & ThisWorkbook.Name Set oLApp = CreateObject("Outlook.Application") Set eMail = oLApp.CreateItem(olMailItem) With eMail .To = " .Subject = "some subject" .Attachments.Add (thisWb) .Display End With Set eMail = Nothing Set oLApp = Nothing End Sub |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
CreateObject("Outlook.Application")
FullName is available in xl2003.
"Howard31" wrote in message ... Thanks Barb Reinhardt! I'll try it out. By the way is "Thisworkbook.fullname" availble in xl2003? "Barb Reinhardt" wrote: FWIW, you can replace thisWb = ThisWorkbook.Path & "\" & ThisWorkbook.Name with thisWS = Thisworkbook.fullname -- HTH, Barb Reinhardt "Howard31" wrote: Hi, I have procedure for sending mail. The problem is that the procedure will work the first time it is executed but not the second time then the third time it will work but not the fourth time and so on. The sendEmail procedure is below. Any help will be very much appreciated! Public Sub sendMail() On Error Resume Next Dim oLApp As Object Dim eMail As Object Dim thisWb As String thisWb = ThisWorkbook.Path & "\" & ThisWorkbook.Name Set oLApp = CreateObject("Outlook.Application") Set eMail = oLApp.CreateItem(olMailItem) With eMail .To = " .Subject = "some subject" .Attachments.Add (thisWb) .Display End With Set eMail = Nothing Set oLApp = Nothing End Sub |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
CreateObject("Outlook.Application")
Thanks JLGWhiz!
"JLGWhiz" wrote: FullName is available in xl2003. "Howard31" wrote in message ... Thanks Barb Reinhardt! I'll try it out. By the way is "Thisworkbook.fullname" availble in xl2003? "Barb Reinhardt" wrote: FWIW, you can replace thisWb = ThisWorkbook.Path & "\" & ThisWorkbook.Name with thisWS = Thisworkbook.fullname -- HTH, Barb Reinhardt "Howard31" wrote: Hi, I have procedure for sending mail. The problem is that the procedure will work the first time it is executed but not the second time then the third time it will work but not the fourth time and so on. The sendEmail procedure is below. Any help will be very much appreciated! Public Sub sendMail() On Error Resume Next Dim oLApp As Object Dim eMail As Object Dim thisWb As String thisWb = ThisWorkbook.Path & "\" & ThisWorkbook.Name Set oLApp = CreateObject("Outlook.Application") Set eMail = oLApp.CreateItem(olMailItem) With eMail .To = " .Subject = "some subject" .Attachments.Add (thisWb) .Display End With Set eMail = Nothing Set oLApp = Nothing End Sub . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
CreateObject("Excel.Application") | Excel Worksheet Functions | |||
CreateObject("InternetExplorer.Application") | Excel Programming | |||
Set OutApp = CreateObject("Outlook.Application") - Runtime error 429 | Excel Programming | |||
ASP: CreateObject("Excel.Application") IIS 6.0 Win2003 | Excel Programming | |||
CreateObject("Excel.Application") - Access denied | Excel Programming |