Overcoming an error when trying to send e-mail in VBA...

Xeroid

Board Regular
Joined
Aug 14, 2002
Messages
64
I have a code in place to send the active file to a given address.

I have one user who keeps getting an error when she tries to run the macro.

Here's the code:
Code:
'Send the file in an Outlook message with formletter:
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 = "me.myself@mycompany.com"
.Subject = "New box list for review - " & ActiveWorkbook.Name
.Body = "Please review the following list of new boxes to be picked up." & Chr(13) & Chr(13)
.Attachments.Add fName
.Display

End With

Set otlNewMail = Nothing
Set otlApp = Nothing
Set otlAttach = Nothing
Set otlMess = Nothing
Set otlNSpace = Nothing
'
End Sub

The error that is generated reads: "Run-time error 429: ActiveX component can't create object".

I am entirely self taught (thanks in greatest part to this board) and I have really no understanding of ActiveX controls.

I notice that this problem only exists for 1 in over 100 users, so I think it is specific to the settings on her PC.

Any advice would be much appreciated so I can get the code to work for her.

(y)

Xeroid.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I'm not sure if this is the solution, but try this on the users machine.

Go to the VBE (Alt +F11)

Tools -> References -> check 'Microsoft Outlook 11.0 Object Library

Regards
Jon
 
Upvote 0
Fixing the ActiveX control to allow e-mail to send in VBA...

Thanks.

I talked with the user over the phone and it basically came down to some company implemented settings that preclude the macro from working. One of those paranoid security settings, I guess.

I guess the 'man' wins this one! I wouldn't be allowed to correct the problem. Even the "Visual Basic for Applications" box was turned off!

Thanks anyway.
 
Upvote 0
User Defined Type Not Defined error...

Hi Jon.

I tried the code in the thread you suggested, but I get a "User Defined Type Not Defined" error...???

:eek:
 
Upvote 0
Ah ok, this is the error I was thinking about before. In the VBE go to Tools > References and check 'Microsoft Outlook 11.0 Object Library'
 
Upvote 0
Xeriod

If the original problem was caused by a security setting then I don't see how any code will make a difference.

Especially when the security setting appears to be preventing code execution.
 
Upvote 0
Thanks anyway fellas!

Thanks anyway. The security thing is simply beyond my control, but I appreciate the time and input.

Regards,

Xeroid.
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,741
Members
449,050
Latest member
excelknuckles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top