-
Aug 9th, 2016, 05:08 AM
#1
Thread Starter
New Member
[RESOLVED] COMException was unhandled "HRESULT: 0x800A03EC"
Good Day
A command that worked 100% previously, and still do on some of the laptops, recently started to give the following error when executing, i.e. to link a vb.net program to Excel:
1. Dim ExcelObj As Microsoft.Office.Interop.Excel.Application
2. ExcelObj = GetObject(, "Excel.Application")
3. ExcelObj.Sheets("mySheet").Range("Q3").Value = 25
As soon as line 3 is activated, then this error appears, “System.Runtime.InteropServices.COMException was unhandled”
“Message=Exception from HRESULT: 0x800A03EC”
As stated, the error recently appeared on two workstations. While on others is still work 100%.
What is causing this error and how can it be resolved?
Tanks in advance.
-
Aug 9th, 2016, 07:31 AM
#2
Re: COMException was unhandled "HRESULT: 0x800A03EC"
If it worked before and now it doesn't you should be looking at what changed on those 2 machines from then to now and how are they different?
I think there are a number of things that can cause that, so most any other input would be speculative at best.
Last edited by kebo; Aug 9th, 2016 at 06:38 PM.
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Aug 9th, 2016, 07:52 AM
#3
Thread Starter
New Member
Re: COMException was unhandled "HRESULT: 0x800A03EC"
Hi Kebo
All I can think of, but a guess at best, is an automatic update of OS or Microsoft software? No other hardware or software have been installed. It is working on a machine with .NET Framework 4.5, not on one with .NET Framework 4.5.1, and works on one with .NET Framework 4.6.1. Upgraded the 4.5.1 to 4.6.1, but still no luck.
On exiting Excel and re-open it, then it works fine again. Let me explain in a bit more detail as follows.
1. The VB.NET open an Excel Template and execute some actions.
2. The user can thereafter execute other required actions via custom ribbon, such as "ExcelObj.Sheets("mySheet").Range("Q3").Value = 25" - This is the line of code generating the error on some machines that worked fine before.
3. However if the program is exited, as well as Excel, and then re-opened and same command executed it works fine. Just a massive issue to exit the program and then redo command again that worked flawless previously and still do on some machines.
Hopefully I just need a patch of some sort...... I am stuck at the moment...............
-
Aug 9th, 2016, 10:20 AM
#4
Re: COMException was unhandled "HRESULT: 0x800A03EC"
On exiting Excel and re-open it, then it works fine again. Let me explain in a bit more detail as follows.
1. The VB.NET open an Excel Template and execute some actions.
2. The user can thereafter execute other required actions via custom ribbon, such as "ExcelObj.Sheets("mySheet").Range("Q3").Value = 25" - This is the line of code generating the error on some machines that worked fine before.
3. However if the program is exited, as well as Excel, and then re-opened and same command executed it works fine. Just a massive issue to exit the program and then redo command again that worked flawless previously and still do on some machines.
I'm not sure I follow this sequence properly. Do you mean that on the first pass through the offending code that all works as expected, but on a second attempt to execute that code that it fails? Shutting down the VB program and Excel and restarting then allows for a single pass again?
-
Aug 11th, 2016, 02:25 AM
#5
Thread Starter
New Member
Re: COMException was unhandled "HRESULT: 0x800A03EC"
Hi TnTinMN
1. Basically a “Master” Excel Workbook is created.
2. The user then executes a required custom action. (This action worked 100% before, but now the above-mentioned error).
3. If the user closes Excel completely and reopens the Workbook, the action is executed without an error.
Hope this help!
-
Aug 11th, 2016, 09:42 PM
#6
Re: COMException was unhandled "HRESULT: 0x800A03EC"
Originally Posted by Longbow2000
Hi TnTinMN
1. Basically a “Master” Excel Workbook is created.
2. The user then executes a required custom action. (This action worked 100% before, but now the above-mentioned error).
3. If the user closes Excel completely and reopens the Workbook, the action is executed without an error.
Hope this help!
I am not seeing the interaction between Excel and your VB code. Does your code create/open this “Master Excel Workbook" and then pass control to the user to work on?
Part of the problem is that I am not that familiar with working with the Ribbon. Does your code respond to the ribbon click to execute the offending code?
Since I have more questions than answers, I will point to the use of GetObject to obtain an Excel application instance. How can you guaranty that the obtained instance is the correct one? Or if it is the correct one that the ActiveWorkbook is the correct one. Your code should obtain a strong Workbook reference to work against.
-
Aug 15th, 2016, 03:11 AM
#7
Thread Starter
New Member
Re: COMException was unhandled "HRESULT: 0x800A03EC"
Hi TnTinMN
Yes, the VB Code creates the “Master Excel Workbook" from various option selections in the main VB application. This then hide / unhide specific rows, columns, add values, etc. to the “Master Excel Workbook".
Then control is passed to the user and via the Ribbon (can also be a plain button) specific action can be performed. Some of the actions require GetObject(, "Excel.Application") and then perform a task. It seems that the “InteropService” connection is not established and hence the error.
If the “Master Excel Workbook" is closed and reopened then the command is executed without an issue.
-
Aug 23rd, 2016, 09:15 AM
#8
Thread Starter
New Member
Re: COMException was unhandled "HRESULT: 0x800A03EC"
Just as an update on how the issue was resolved....
When the "Master Excel Workbook" is created, then closed via the VB.NET code, the Excel process is still running in the background. When it is re-opened, the Task Manager list that there are two Excel processes running. One with the "Master Excel Workbook" and the other with no Workbook.
Each time the GetObject(, "Excel.Application") is called and reference is made to a sheet or cell the error appears as it is referring to the Excel process with no Workbook, i.e. empty process.
The VB.NET code needs to ensure that Excel process is completely closed, achieve via this code:
''2016 Make sure Excel is closed
Dim dateEnd As Date = Date.Now
End_Excel_App(datestart, dateEnd)
Private Sub End_Excel_App(datestart As Date, dateEnd As Date)
'End Excel Process
Dim xlp() As Process = Process.GetProcessesByName("EXCEL")
For Each Process As Process In xlp
'If Process.StartTime >= datestart And Process.StartTime <= dateEnd Then
If Process.StartTime <= dateEnd Then
Process.Kill()
Exit For
End If
Next
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|