Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Set OutApp = CreateObject("Outlook.Application") - Runtime error 429

Send Emails

Ok -

I have the following code (posted at bottom) that errors out at

**Set OutApp = CreateObject("Outlook.Application")**

the error message is

Run-time error 429
ActvieX component cannot create object


I have the reference set
(You must add a reference to the Microsoft outlook Library.

1) Go to the VBA editor, Alt -F11
2) ToolsReferences in the Menu bar
3) Place a Checkmark before Microsoft Outlook 9 Object Library
)


It works on other machines (PCs with the same build as mine) so where
am i going wrong?


Sub sendEmails()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim cell As Range

Application.ScreenUpdating = False


Set OutApp = CreateObject("Outlook.Application")

On Error GoTo cleanup
For Each cell In Sheets("Send
Emails").Columns("B").Cells.SpecialCells(xlCellTyp eConstants)
If cell.Offset(0, 1).Value < "" Then
If cell.Offset(0, 1).Value < "" Then

Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = cell.Value
.Subject = "Budget for " & cell.Offset(0, 2).Value
.Body = "Dear " & cell.Offset(0, -1).Value & vbCrLf &
vbCrLf
.Body = .Body & "Please find attached latest update
showing the actuals against budget for " & cell.Offset(0, 2).Value &
vbCrLf & vbCrLf

If cell.Offset(0, 3) < "" Then
.Body = .Body & cell.Offset(0, 3).Value & vbCrLf &
vbCrLf
End If
If cell.Offset(0, 4) < "" Then
.Body = .Body & cell.Offset(0, 4).Value & vbCrLf &
vbCrLf
End If
.Body = .Body & "If you have any queries
- please let me know. " & vbCrLf & vbCrLf
.Body = .Body & "Many thanks " & vbCrLf & vbCrLf
.Body = .Body & "Systems Finance Team" & vbCrLf &
vbCrLf
.Attachments.Add cell.Offset(0, 1).Value
.Display 'Or use Display
If cell.Offset(0, 5) = "Y" Then
.ReadReceiptRequested = True
Else
.ReadReceiptRequested = False
End If
End With
Set OutMail = Nothing
End If
End If
Next cell
Exit Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Set OutApp = CreateObject("Outlook.Application") - Runtime error 429

i tried

Private Sub Form_Click()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\testfile.txt", True)
a.WriteLine ("This is a test.")
a.Close
End Sub

which worked...?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Set OutApp = CreateObject("Outlook.Application") - Runtime error 429

Hi Buffyslay

Start with this KB
http://support.microsoft.com/default...b;en-us;828550

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Buffyslay" wrote in message oups.com...
Send Emails

Ok -

I have the following code (posted at bottom) that errors out at

**Set OutApp = CreateObject("Outlook.Application")**

the error message is

Run-time error 429
ActvieX component cannot create object


I have the reference set
(You must add a reference to the Microsoft outlook Library.

1) Go to the VBA editor, Alt -F11
2) ToolsReferences in the Menu bar
3) Place a Checkmark before Microsoft Outlook 9 Object Library
)


It works on other machines (PCs with the same build as mine) so where
am i going wrong?


Sub sendEmails()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim cell As Range

Application.ScreenUpdating = False


Set OutApp = CreateObject("Outlook.Application")

On Error GoTo cleanup
For Each cell In Sheets("Send
Emails").Columns("B").Cells.SpecialCells(xlCellTyp eConstants)
If cell.Offset(0, 1).Value < "" Then
If cell.Offset(0, 1).Value < "" Then

Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = cell.Value
.Subject = "Budget for " & cell.Offset(0, 2).Value
.Body = "Dear " & cell.Offset(0, -1).Value & vbCrLf &
vbCrLf
.Body = .Body & "Please find attached latest update
showing the actuals against budget for " & cell.Offset(0, 2).Value &
vbCrLf & vbCrLf

If cell.Offset(0, 3) < "" Then
.Body = .Body & cell.Offset(0, 3).Value & vbCrLf &
vbCrLf
End If
If cell.Offset(0, 4) < "" Then
.Body = .Body & cell.Offset(0, 4).Value & vbCrLf &
vbCrLf
End If
.Body = .Body & "If you have any queries
- please let me know. " & vbCrLf & vbCrLf
.Body = .Body & "Many thanks " & vbCrLf & vbCrLf
.Body = .Body & "Systems Finance Team" & vbCrLf &
vbCrLf
.Attachments.Add cell.Offset(0, 1).Value
.Display 'Or use Display
If cell.Offset(0, 5) = "Y" Then
.ReadReceiptRequested = True
Else
.ReadReceiptRequested = False
End If
End With
Set OutMail = Nothing
End If
End If
Next cell
Exit Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CreateObject("Excel.Application") Olivia Towery Excel Worksheet Functions 4 June 12th 06 12:07 AM
ASP: CreateObject("Excel.Application") IIS 6.0 Win2003 Mau[_2_] Excel Programming 0 July 20th 05 11:45 AM
Why does Outlook.Application.GetNamespace("MAPI") Fail? Lee Excel Programming 4 May 27th 05 02:15 PM
Excel:Runtime Error 7 "Not enough Memory" with CreateObject (SAP.B sebastienm Excel Programming 0 July 24th 04 08:35 AM
CreateObject("Excel.Application") - Access denied Luca[_2_] Excel Programming 0 February 6th 04 01:21 PM


All times are GMT +1. The time now is 03:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"