Outlook VB not working
Hi Ron, we have used this code in our EXCEL sheets (we have 4 excel sheets we
send several times a day) for over a year and it is a life saver I really
appreciate you allowing it's use.
The old saying "when all else fails read the instruction" well on my list of
thing to check or do was 'detect and repair' I just done a 'detect and
repair' on my EXCEL and now it is working just fine. I should have tried that
before i came to the forum but you live and learn to step back and look
before you leap.
Thank you for your quick responce and advise.
"tankerman" wrote:
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
|