0

I have used Imports Microsoft.Office.Interop and Reference of Microsoft excel is added to project/solution

Following are declaration

 Public xlsfilepath As String
 Public oxlsapp As New Excel.Application
 Public oxlsworkbook As Excel.Workbook
 Public oxlsworksheet As Excel.Worksheet
 Public oxlcellsrange As Excel.Range
 Dim xchar As String

Cell reading process from existing file

oxlcellsrange = oxlsworksheet.Cells(iRow, iCol)
MessageBox.Show(oxlsworksheet.Range(oxlcellsrange).Value)<----Here gives fatal error 

System.Runtime.InteropServices.COMException: 'Exception from HRESULT: 0x800A03EC'

Don't understand why?

Image is attached for that describes more.

Error message

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Hemu
  • 13
  • 5

3 Answers3

0

Reference of Microsoft excel is added to project/solution.

There's a confusing thing about Office Development. You need to reference the Private Interop Assemblies VSTO vs. Primary Interop Assemblies, what's the difference?

You might have mistakenly referenced the COM references and they're only supposed to be used in for UnitTesting Mocks of Office: https://stackoverflow.com/a/47256597/495455

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
0

Excel COM references were set up correctly due to the fact that previous lines of code are working without errors. Moreover, that is a runtime error.

This is a widely-spread error when dealing with the Excel object model. You may find a similar posts like Exception from HRESULT: 0x800A03EC Error popular.

The Worksheet.Range property accepts a string that is a range reference when one argument is used. Either a string that is a range reference or a Range object when two arguments are used. For example:

Worksheets("Sheet1").Range("A1").Value = 3.14159
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
0

I perform following steps and my error gone/resolved

1-Run > type > dcomcnfg > it open component service window (as administrator)

In that window

2-Go to Component service > Computers > MyComputer > DCOM Config

3-All services will list

4-select Microsoft Excel in the list and right click on it.

5-In property window go to > identity TAB

6-I selected The Launching User Radio Button and Applied it.

7-Then My Error resolved.

but it amuse me.

Hemu
  • 13
  • 5