Cannot create ActiveX component after upgrading software

Torquinian 1 Reputation point
2025-01-23T15:05:59.0633333+00:00

A customer has recently had their Office software upgraded to Office 365 and now the bespoke software they use will not send e-mails, instead they get the error "Cannot create ActiveX component".

I have looked at some of the other cases online where this error is mentioned, but I have not found any that seem to fit this situation.

The bespoke software is created using Visual Basic in Visual Studio 2013, with a Target CPU of x86 and a Target Framework of .NET Framework 4. The machine that the software is on is running Windows 10 Pro 10.0.19045 Build 19045. The version of Outlook is 2409, Build 18025.20140 Click to Run. The version of the Microsoft.Office.Interop.Outlook.dll is 14.0.4760.1000 (Size 950 kb).

Outlook states that the "Microsoft VBA for Outlook Addin" is Inactive, if that is relevant.

Could anyone suggest ways that I could try to solve this problem?

I have looked on their system and tried:- Putting the Microsoft.Office.Interop.Outlook.dll file into the folder which holds the EXE file. Putting the Microsoft.Office.Interop.Outlook.dll file into the System32 folder. Putting the Microsoft.Office.Interop.Outlook.dll file into the SysWow64 folder.

I have looked at HKEY_CLASSES_ROOT\Outlook.Application.16, right clicked and looked at the Permissions - Administrators have the Full Control box ticked but Users do not.

I have looked at some of the other cases online where this error is mentioned, but I have not found any that seem to fit this situation.

Private Sub btnemail_Click(sender As System.Object, e As System.EventArgs) Handles btnemail.Click
    Dim emailadd As String = ""
    Dim cownt As Integer = 0

    Using conn As New SqlConnection
        Try
            conn.ConnectionString = ConnectionString

            Dim command2 As New SqlCommand("CustSelEmail", conn)
            command2.CommandType = CommandType.StoredProcedure
            command2.Parameters.Add(New SqlParameter("@Nick", NickNom))
            Dim SQLParamOP As New SqlParameter("@Workd", "")
            SQLParamOP.Direction = ParameterDirection.Output
            command2.Parameters.Add(SQLParamOP)

            conn.Open()
            Dim reader As SqlDataReader = command2.ExecuteReader

            While reader.Read
                emailadd = reader(0).ToString
            End While
            conn.Close()

            If emailadd = "" Then
                MsgBox("There is no email address for this Customer account")
                Exit Sub
            End If

            If My.Computer.FileSystem.FileExists("Filename" & NickNom & ".pdf") = True Then
                My.Computer.FileSystem.DeleteFile("Filename" & NickNom & ".pdf", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin)
            End If

            crreportdocument.ExportToDisk(ExportFormatType.PortableDocFormat, "Filename" & NickNom & ".pdf")

            Dim myolapp As Object
            myolapp = GetObject("Outlook.Application")
            Dim mailItem As Outlook.MailItem = myolapp.CreateItem(Outlook.OlItemType.olMailItem)
            mailItem.Subject = "Company Invoice"
            mailItem.To = emailadd
            mailItem.Body = "Invoice is attached."
            mailItem.Importance = Outlook.OlImportance.olImportanceNormal
            mailItem.Attachments.Add("Filename" & NickNom & ".pdf", Outlook.OlAttachmentType.olByValue, 1, "Filename" & NickNom & ".pdf")
            mailItem.Display(True) 'Shows the email on screen

            mailItem = Nothing
            myolapp = Nothing

        Catch ex As Exception
            If ex.GetBaseException.Message = "Cannot create ActiveX component." And cownt < 25 Then 'For Outlook 2010
                cownt = cownt + 1 'To stop infinite loop when genuine error
                GoTo Create
            End If
            MsgBox(ex.GetBaseException.Message, MsgBoxStyle.OkOnly, " e-mail")
            Error_Log(modname, cboCustFrom.Text & " - " & cboCustTo.Text, ex, "e-mail")
        Finally
            conn.Close()
        End Try
    End Using
End Sub
Outlook
Outlook
A family of Microsoft email and calendar products.
4,373 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,182 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 56,446 Reputation points
    2025-01-23T15:33:40.5533333+00:00

    Firstly, don't copy an interop assembly into other paths. This will potentially cause unrelated apps that are using interop to fail. You need to clean up anything you copied. This is not solving anything as the problem isn't a pathing issue most likely.

    There are a couple of things that could be going on here.

    1. Newer versions of Office are x64, not x86. Check the path where Office is installed. If it is installed under Program Files then you're now using x64 and x86 COM objects cannot be used. The COM component would need to be updated to x64 and re-registered with the system.
    2. "New" Outlook, not to be confused with the current "Old" Outlook doesn't support COM anymore. This is a complete rewrite of the system and legacy add-ins/COM aren't supported. There is no workaround. You would need to migrate your functionality into a supported add-in model for the new app. Refer to the following article on supported options going forward.
    3. You didn't mention it, that I can see, but does your COM object actually show up under the list of COM objects when you go to Manage COM Add-ins? If it doesn't then it isn't registered (or you're running x64) and so you need to ensure it is registered properly.

    To be honest, there is a very good chance that your legacy COM component simply isn't supported anymore under the newer Office versions. Given the age of the component you mentioned I wouldn't be surprised if this is the case. You need to prioritize replacing it with a modern, supported approach.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.