VB.NET error

  • Thread starter Thread starter Gary
  • Start date Start date
G

Gary

Hi,

I have a VB 6.0 code that has been migrated to VB.NET.

This code basically writes data to an Excel file.

On execution of the migrated VB.NET code, I get an error:

-------------------------------------------------------------------------------------------

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll



Additional information: Exception from HRESULT: 0x800A03EC.

--------------------------------------------------------------------------------------------



Please help !

- Gary
 
Hi Gary,

No Help appears to be available from MSDN for that error code. Can you indicate during execution of what line did that error occur?

Regards

Narayan
Hi,

I have a VB 6.0 code that has been migrated to VB.NET.

This code basically writes data to an Excel file.

On execution of the migrated VB.NET code, I get an error:

-------------------------------------------------------------------------------------------

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll



Additional information: Exception from HRESULT: 0x800A03EC.

--------------------------------------------------------------------------------------------



Please help !

- Gary
 
Gary said:
I have a VB 6.0 code that has been migrated to VB.NET.

This code basically writes data to an Excel file.

On execution of the migrated VB.NET code, I get an error:

-------------------------------------------------------------------------- -----------------

An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in
mscorlib.dll



Additional information: Exception from HRESULT: 0x800A03EC.

--------------------------------------------------------------------------
 
Hello,

Gary said:
I have a VB 6.0 code that has been migrated to VB.NET.
This code basically writes data to an Excel file.
On execution of the migrated VB.NET code, I get an error:

An unhandled exception of type 'System.Runtime.InteropServices.
COMException' occurred in mscorlib.dll

Help impossible without code.
 
Thanks for replying.
This is the line of code that causes the error:
ExcelGlobal_definst.Selection.Subtotal(GroupBy:=3,
Function:=Excel.XlConsolidationFunction.xlSum, TotalList:=New Object() {8,
9, 10, 11, 13, 14, 16, 17, 19, 21, 22, 24, 25, 26, 27, 28},
Replace_Renamed:=True, PageBreaks:=False, SummaryBelowData:=False)

Thanks again,
Gary
 
Hi Gary,

Firstly there appears to be no named parameter in the method called
Replace_Renamed. Try changing this to Replace: = True.

Another thing:
This appears to be macro recorded code pasted into the project. As you are
probably already aware, MS recommeds this (macro recording) only as a
learning tool. Code generated by recording a Macro is often inefficient
code. An immediate problem that I see with macro recorded code is that it
almost always produces late bound code.

Another thing is that it always uses the Global Selection Property (of the
Application Object). We generally expect it to be a Worksheet Range, but
this could well be an Embedded Chart Object, in which case methods of the
Range object that we use are bound to fail at runtime(but will compile!!).
But if you use something like Worksheet.Cells(x,y), it is less likely to
fail.

It would probably be better to write something like this:

Dim R As Excel.Range
Set R = Ws.Cells(2, 2)

R.Subtotal(3, XlConsolidationFunction.xlSum, New Int32() {3, 4, 5}, True,
False, XlSummaryRow.xlSummaryBelow)

Hope this helps

Narayan
 
Back
Top