Erro 429 "Activex não pode criar o objeto" no Windows 7

ForteLeandro

22-01-2013 18:16:48

Olá,

Estou com problema em uma aplicação, onde estava funcionando normalmente no windows XP, mas após instalar Windows 7 temos erro no trecho "Set OutApp = CreateObject("Outlook.Application")" e a seguinte mensagem: Erro 429 "Activex não pode criar o objeto";

Grato pela ajuda!

segue código:

Sub Novo_EnviaEmail()

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim Email As String
Dim Assunto As String
Dim Corpo As String
Dim Diretorio As String
Dim temp As Range

Diretorio = Cells(1, 5).Value
Assunto = Cells(2, 5).Value
Corpo = Cells(3, 5).Value

For i = 2 To 10000
'sai do for quando chegar no final
If Cells(i, 1).Value = "" Then Exit For

'só manda se conseguiu pegar o email
'senão sinaliza um erro
Email = Cells(i, 2).Value
If Trim(Email) <> "" Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)

'busca os arquivos que vai inserir
With Worksheets(1).Range("A4:A5000")
Set c = .Find(Cells(i, 1).Value, LookIn:=xlValues, LookAt:=xlPart)
If Not c Is Nothing Then
firstAddress = c.Address
Do
OutMail.Attachments.Add c.Value
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With

'termina de montar o email
With OutMail
.To = Email
.Subject = Assunto
.Body = Corpo
.SentOnBehalfOfName = "leandro.forte@claro.com.br"
.Send
End With
Cells(i, 3).Value = "Enviado!"

'limpa o email e envia
Set OutMail = Nothing
Set OutApp = Nothing
Application.Wait (Now + TimeValue("0:00:01"))

Else
Cells(i, 3).Value = "Erro!"
End If

Next i


Application.StatusBar = False
End Sub