none
VBA Excel Interface Not Registered - Runtime Error '-2147221163 (80040155)' RRS feed

  • Question

  • Hello Everyone,

    This is a recent problem that just appeared this morning. The code is a VBA macro (not VB.Net) from Solidworks (CAD software) that opens and reads an Excel sheet before returning back to Solidowrks. It's currently running fine on two other network computers, and was running fine on this one until this morning. Operating system is Windows 10.

    Here is a snippet of the code: (error occurs on line three)

    Dim xlApp As Excel.Application
    Dim xlWB As Excel.Workbook

    Sub main()

        Set swApp = Application.SldWorks
        Set swModel = swApp.ActiveDoc

        Set xlApp = New Excel.Application
        xlApp.Visible = False

    Using this code for late-binding does not work either, however this brings up an ActiveX error.

    Dim xlApp As Excel.Application
    Dim xlWB As Excel.Workbook

    Sub main()

        Set swApp = Application.SldWorks
        Set swModel = swApp.ActiveDoc

        Set xlApp = CreateObject("Excel.Application")
        xlApp.Visible = False

    This brings up an error "ActiveX cannot create object."

    I've tried with different object libraries. The standard throughout the workplace is the Excel 14.0 object library. (Computer is currently running Excel 2019). I've tried with the Excel 16.0 object library and it made no difference.

    Any thoughts on where this problem could be coming from?

    Thanks in advance.

    Edit: This topic has been re-posted to the correct VBA forum instead of VB.Net. (That thread has the same title)
    Wednesday, January 8, 2020 5:04 PM

All replies

  • Hello,

    What is SW ?

    In regards to

    It's currently running fine on two other network computers, and was running fine on this one until this morning. 

    Then its (of course you realize this) an environmental issue which is unrelated to VB.NET code. So the solution is to find out what is different between the computer which works and then one that does not past the OS.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, January 8, 2020 5:20 PM
  • Karen,

    SW is just an abbreviation for Solidworks, which is CAD software.

    I understand there must have been some change on the problem computer, however I am self-taught in VB so I'm confident there are places I don't know to look.

    Wednesday, January 8, 2020 5:35 PM
  • Karen,

    SW is just an abbreviation for Solidworks, which is CAD software.

    I understand there must have been some change on the problem computer, however I am self-taught in VB so I'm confident there are places I don't know to look.

    VB.NET has nothing to do with the issue, it's environmental outside of code.



    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, January 8, 2020 5:48 PM
  • Karen,

    I understand it's not a coding issue, as the code works fine elsewhere. I'm looking for help identifying where that change could be, or ideally a more universal/robust method for adding the object libraries that would not be subject to seemingly random changes.

    Wednesday, January 8, 2020 6:35 PM
  • Karen,

    I understand it's not a coding issue, as the code works fine elsewhere. I'm looking for help identifying where that change could be, or ideally a more universal/robust method for adding the object libraries that would not be subject to seemingly random changes.

    Okay, EPPlus is a great choice yet all examples are in C# but take the documentation should make it easier to use in VB.NET (and we only deal with VB.NET in this forum). Add the library from NuGet.

    Personally I've not done anything with Excel automation in over 15 years as this is problematic while using libraries that don't depend on Excel to even be installed is better which is why I use GemBox Excel library (and its not cheap but worth it many times over).


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Wednesday, January 8, 2020 6:46 PM