Excel 2010处理与Excel 2007不同的OLEObject [英] Excel 2010 treats OLEObjects different from Excel 2007
问题描述
我已经为Excel实现了一个ATL C ++ COM加载项。它将OLEObject嵌入到电子表格中。如果从电子表格中删除连接的单元格,我的对象也应该消失。这在Excel 2007中运行良好但我无法在2010年使用。在2007年
以下工作:
I've implemented an ATL C++ COM add-in for Excel. It embeds an OLEObject into a spreadsheet. If the connected cell is deleted from the spreadsheet my object should disappear too. This works fine in Excel 2007 but I cannot make it work in 2010. In 2007 the following works:
>在Excel :: AppEvents :: SheetChange 我检查连接的单元格是否已被删除。
>如果是这样,我在连接的OLEObject上调用Excel :: _ OLEObject :: Delete()。
> Excel 2007然后释放对我的对象的引用,以便它被删除。
> On Excel::AppEvents::SheetChange I check if the connected cell has been deleted.
> If so, I call Excel::_OLEObject::Delete() on the connected OLEObject.
> Excel 2007 then releases references to my object so that it gets deleted.
- 这需要几个月的时间才能使用引用计数等工作,所以我宁愿不改变它!但是,在Excel 2010中会发生以下情况:
- it has taken months to make this work with reference counting etc. so I'd rather not change this! However, in Excel 2010 the following happens:
>在Excel :: AppEvents :: SheetChange 我检查已连接的单元格是否已被删除(与上面相同)
>如果是这样,调用Excel :: _ OLEObject :: Delete()会抛出异常("未知错误0x800A03EC")。实际上,如果我此时尝试获取Excel :: _ OLEObject :: TopLeftCell,则返回NULL(与Excel 2007不同)。
>无论我尝试什么,我只在Excel 2010中看到两种可能的结果:
1>要么因为错误的引用计数而挂起Excel,要么
2>或者我的对象保持活着直到电子表格关闭。
> On Excel::AppEvents::SheetChange I check if the connected cell has been deleted (same as above)
> if so, calling Excel::_OLEObject::Delete() throws an exception ("Unknown error 0x800A03EC"). Actually, if I try to get Excel::_OLEObject::TopLeftCell at this point it returns NULL (which is different from Excel 2007).
> No matter what I try I only see two possible outcomes in Excel 2010:
1> either I hang Excel due to wrong reference counting
2> or my object stays alive until the spreadsheet is closed.
删除单元格后,我需要我的对象消失 - 我不能等到电子表格关闭。我试图听取Excel中的所有方法调用和通知,但我没有看到任何方法使它工作。我想我应该调用Excel :: _ OLEObject :: Delete()
,而我对Excel :: _ OLEObject的引用仍然存在,但它似乎在我知道单元格消失之前就已经死了。
I need my object to disappear as soon as the cell is deleted - I cannot wait until the spreadsheet is closed. I've tried to listen to all method calls and notifications from Excel but I don't see any way to make it work. I guess I should call Excel::_OLEObject::Delete() while my reference to Excel::_OLEObject is alive but it seems to die before I know that the cell is gone.
到目前为止,几周的实验都失败了。怎么办?
Weeks of experiments have failed so far. What to do?
推荐答案
你好 borum ,
感谢发布。
我试图让某人熟悉这个问题。所以,可能会有一些延迟。
感谢您的耐心等待。
最好的问候,
这篇关于Excel 2010处理与Excel 2007不同的OLEObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!