Cannot Get Instance of Com component Microsoft.Office.Interop.Excel.Worksheetwith Excel Interface Er

M

Michael G.

There is one UI instance of Excel 2007 up with an error message and
when I try to instantiate the worksheet component through VB.Net I get
this error: It seems that the UI instance is blocking access to the
worksheet component.

VB.Net Error:
"Creating an instance of the COM component with CLSID
{00020820-0000-0000-C000-000000000046} from the IClassFactory failed
due to the following error: 80010001."


Excel UI Error:
The file you are trying to open test.xls is in a different format than
specified by the file extension.

VB.Net Code:
Dim MainWorkSheet As New Microsoft.Office.Interop.Excel.Worksheet
 
F

filip

There is one UI instance of Excel 2007 up with an error message and
when I try to instantiate the worksheet component through VB.Net I get
this error:  It seems that the UI instance is blocking access to the
worksheet component.

VB.Net Error:
"Creating an instance of the COM component with CLSID
{00020820-0000-0000-C000-000000000046} from the IClassFactory failed
due to the following error: 80010001."

Excel UI Error:
The file you are trying to open test.xls is in a different format than
specified by the file extension.

VB.Net Code:
 Dim MainWorkSheet As New Microsoft.Office.Interop.Excel.Worksheet

What library did you referance? Excel 11.0 or 12.0? If you have Excel
2007 then you have 12.0 library which can't read xls files, just xlsx
files. 11.0 reads xls files. So if you want to read that file get
yourself Excel 2003.
Other way to solve this is to use GemBox.Spreadsheet component. It is
not dependable on any Excel version so you won't have problems like
this. Take a look: http://www.gemboxsoftware.com/GBSpreadsheet.htm
 
C

Chip Pearson

then you have 12.0 library which can't read xls files, just xlsx files.

What? 12 can read any Excel format going back to at least 4 if not
earlier.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
P

Peter T

While an Excel dialog is displayed normally you cannot automate Excel. This
can pose a dilemma if you are not sure what the dialog is, why it is
displaying and is it waiting for the user to handle (whilst gone for a
coffee) or triggered due to some action of your own code.

Assuming at least you have an object reference to the application you can
try something like this (either in advance or after catching the error)

If xlApp.Ready = False then
some dialog showing or user in edit mode
loop with a timer until .Ready = true or abort
or perhaps even SendKeys (or API equivalent) an Esc to dismiss the known
dialog


Regards,
Peter T
 
P

Peter T

As Chip has pointed out this is not an Excel version/library issue. This
error message will show even if manually user attempts to open (say) an xlsx
that has been renamed xls.

Very often in the last few weeks I've noticed Gembox being promoted as the
solution to some problem even though it has nothing to do with the actual
issue of the thread, yet alone a solution.

I'm sure you mentioned the library reference in good faith, but can I ask if
you are in some way connected with Gembox.

Regards,
Peter T
 
P

Peter T

PS
I should have clarified it's not possible to check the .Ready state with all
dialogs and situations, though in a quick check it should work with your
particular error message.

Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top