Hi Than_seji!
I am Shakiru, an independent advisor and a user like you, and I am glad to be helping you out today.
The error you’re encountering is typically related to the COM registration of the Excel application not being correct or not matching the expected interface.
- Make sure that the version of the Microsoft.Office.Interop.Excel assembly referenced in your project matches the version of Excel installed on your machine. Since you’re using Excel 2019, you might need to update the reference to the appropriate version if it’s currently set to an older version.
- You may need to manually register the Excel interop assemblies using regasm.exe. This tool can be found in the .NET Framework installation directory. You’ll need to run it with administrator privileges.
- Verify that your Visual Studio project’s configuration is set to the correct platform target (x86 or x64) that matches your Office installation.
Please try this to check the assembly version in your project:
Imports System.Reflection
Public Sub CheckAssemblyVersion() Dim excelAssembly As Assembly = Assembly.Load("Microsoft.Office.Interop.Excel") Console.WriteLine($"Assembly version: {excelAssembly.GetName(). Version}") End Sub
Please let me know how it goes and if you need any other assistance and I will be more than happy to help further.
Thank you
Best Regards, Shakiru