View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
tankerman tankerman is offline
external usenet poster
 
Posts: 60
Default Outlook VB not working

Our PC at work when bad and was replaced witn a new one that is supposed be
exactly the same, but now I am getting a runtime error 429. when I debug it
highlights this line

Set OutApp = CreateObject("Outlook.Application")

do you have any idea of what is wrong. It worked great until they replace
our PC.
I have included the code below. We are using 2003


Option Explicit

Sub Mail_Sheet_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set rng = Nothing
Set rng = ActiveSheet.UsedRange


Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = Range("B14")
.HTMLBody = RangetoHTML(rng)
.Send
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing
End Sub