tags:

views:

657

answers:

1

A sample I'm working on calls CoCreateInstance for class Microsoft_Office Excel Worksheet. It fails with HRESULT of 0x80040514 ("Class not registered"). Other Excel classes (Excel.Application) are registered on the system, but not the one for Worksheet .....Is it possible to register this class?

Update: I'm using Microsoft's DSOFramer sample project. It first tries to bind using an IMoniker class. If that fails, it calls CoCreateInstance for the clsid. This may work for other MS Office objects, but when it's Excel, the class is for the Worksheet. I modified the sample to CoCreateInstance _Application, then got the workbooks, then called the Workbooks::Open for the target file, which returns a Worksheet object. I then returned that pointer and merged back with the original sample code path. All working now.

+1  A: 

I believe that you may have a botched install. I have found that when my progIds are corrupted like that if I repair the installation that it will register that class.

Though my question back to you is, why are you trying to create a sheet object? Seems like you can get one from off of a Workbook object. In fact I feel this is probably what you'll need to do anyway.

This is actually what I ended up doing last night. Microsoft's DSOFramer sample project calls CoCreateInstance for the clsid when the IMoniker bind fails. I modified the sample to CoCreateInstance _Application, then navigated the objects to get the worksheet, then merged with original code. Thanks!
Steve