Creating Outlook object in 0ffice 2016 (1 Viewer)

DenMiller57

Registered User.
Local time
Today, 03:04
Joined
May 3, 2006
Messages
13
I have some Access VBA code that creates an Outlook object and attaches a few documents to it, then displays the email in Outlook ready for me to click the Send button, after reviewing the attachments. This code worked great for many years under Office 2010 and Office 2013. I purchased a new computer which has Office 2016. The code no longer works. When the code attempts to create an Outlook object, the program displays the error #429 "Active X component can't create object" is generated. I have posted the code below. The last line in the code generates the error. I have searched Microsoft VBA Help and their examples are exactly what I am using. I have tried using all the Active X libraries, thinking I needed one of them, with no change. The overall desktop program has thousands of lines of code. This is the only portion of the code which has issues in Office 2016. Thanks

Function SendMessage(DisplayMsg As Boolean, Optional AttachmentPath1, Optional AttachmentPath2, Optional AttachmentPath3, Optional AttachmentPath4)

On Error GoTo SendMessage_Error
Dim objOutlook As New Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
 

DenMiller57

Registered User.
Local time
Today, 03:04
Joined
May 3, 2006
Messages
13
Here are the Reference Libraries the program uses.
Visual Basic for Applications
Microsoft Access 16.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
Microsoft Runtime script
Microsoft XML v3.0
Microsoft Outlook 16.0 Object Library
Microsoft Word 16.0 Object Library
 

Micron

AWF VIP
Local time
Today, 04:04
Joined
Oct 20, 2018
Messages
3,476
suggest you try Dim objOutlook As Object
 

DenMiller57

Registered User.
Local time
Today, 03:04
Joined
May 3, 2006
Messages
13
After much hair pulling, I determined that I needed to try a repair on the Office installation and that fixed the Message code. It also eliminated another problem I was having in another procedure which was telling a query was corrupt regardless of whether it was a query or an SQL statement. When all else fails, repair or reinstall Office.
Dennis
 

Users who are viewing this thread

Top Bottom