Hi-
I have been running a macro to send a workbook via email for some time now without any issues.
I have recently had my laptop rebuilt for windows 2007 and now the macro is giving me a Run-time error '429'. ActiveX component can't create object.
Any ideas? Code is below; I have highlighted the line of code that seems to be causing the problem.
Any help would be much appreciated.
Thanks,
Sub SendWB()
'
'
Filename = InputBox("Please provide a name for this request")
ThisWorkbook.SaveAs (Environ("userprofile") & Application.PathSeparator & "Desktop" & Application.PathSeparator & Filename)
Dim myOutlook As Object
Dim myMailItem As Object
Set otlApp = CreateObject("Outlook.Application")
Set otlnewmail = otlApp.CreateItem(olMailItem)
fname = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
With otlnewmail
.To = Cells(2, 5)
.CC = Cells(2, 3)
.Subject = "Amendment Request " & Filename
.Body = "Please review the attached amendment request " & Filename
.Attachments.Add fname
.Display
End With
Set otlnewmail = Nothing
Set otlApp = Nothing
Set otlAttach = Nothing
Set otlMess = Nothing
Set otlNSpace = Nothing
End Sub
I have been running a macro to send a workbook via email for some time now without any issues.
I have recently had my laptop rebuilt for windows 2007 and now the macro is giving me a Run-time error '429'. ActiveX component can't create object.
Any ideas? Code is below; I have highlighted the line of code that seems to be causing the problem.
Any help would be much appreciated.
Thanks,
Sub SendWB()
'
'
Filename = InputBox("Please provide a name for this request")
ThisWorkbook.SaveAs (Environ("userprofile") & Application.PathSeparator & "Desktop" & Application.PathSeparator & Filename)
Dim myOutlook As Object
Dim myMailItem As Object
Set otlApp = CreateObject("Outlook.Application")
Set otlnewmail = otlApp.CreateItem(olMailItem)
fname = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
With otlnewmail
.To = Cells(2, 5)
.CC = Cells(2, 3)
.Subject = "Amendment Request " & Filename
.Body = "Please review the attached amendment request " & Filename
.Attachments.Add fname
.Display
End With
Set otlnewmail = Nothing
Set otlApp = Nothing
Set otlAttach = Nothing
Set otlMess = Nothing
Set otlNSpace = Nothing
End Sub