具有无缝撤消功能的 Excel 加载项:可能吗?
我正在考虑使用 COM(而不是 VBA)实现一个 Excel 加载项,该加载项将操作工作表中的数据。
我将需要此插件与撤消堆栈无缝集成。 更具体地说:
- 此加载项对数据所做的任何更改都需要由用户撤消(通过标准撤消操作)
- 在加载项操作发生之前撤消堆栈上的项目需要保留
在我的(尽管是敷衍了事)中)到目前为止的研究,尚不清楚 Excel 是否允许这样做。如果没有,这就是一个阻碍,并且该加载项将没有任何价值。
我的问题:可能吗?这更像是一个“是或否”的问题,而不是一个“如何”的问题,因为我需要知道我是否正在开始徒劳的追逐。然而,任何关于如何做到这一点的指示都将是一个额外的好处。
I am considering implementing an Excel add-in using COM (not VBA) that will manipulate data in the worksheet.
I am going to need this add-in to seamlessly integrate with the Undo stack.
More specifically:
- Any changes this add-in makes to the data need to be undoable by the user (through the standard Undo action)
- The items on the Undo stack before the add-in action takes place need to be preserved
In my (albeit perfunctory) research so far, it is unclear whether or not Excel can allow for this. If it does not, this is a showstopper, and the add-in will have no value.
My question: is it possible? This is more of a "yes or no" question than a "how" question, as I need to know if I am embarking on a wild goose chase or not. However, any pointers on how it can be done would be a bonus.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看来终究是不可能了。
Application.OnUndo
方法清除当前撤消堆栈并将其自身置于顶部。似乎没有任何其他与自定义撤消相关的内容。
这是可能的。Application.OnUndo
为当前正在执行的子程序注册一个撤消子程序:显然,在野外保存先前的状态通常是恶梦。但你走了。
此外,您的撤消子项需要对公众可见,以便 Excel 可以找到并调用它。
Seems like it is not possible after all.
The
Application.OnUndo
method clears the current undo stack and places itself on top.There doesn't seem to be anything else related to customizing undo.
It is possible.Application.OnUndo
registers an undo sub for the currently executing sub:Obviously, saving a previous state in the wild is generally a nightmare. But here you go.
Also, your undo sub will need to be visible to the general public so that Excel can find and call it.
显然,这是不可能的,而且根据 MSFT 员工对此的回应,即使在 Office 2013 中也没有计划支持它 线程。
Apparently, this is not possible and there are no plans to support it even in Office 2013, as per the response by an MSFT employee on this thread.
看起来毕竟是可能的
这是可以完成的,但是您必须编写一个非常复杂的撤消处理程序。
这是一个可以准确告诉您的链接
如何:http://www.jkp-ads.com/Articles/UndoWithVBA01.asp
幸运的是,该链接有完整的源代码,而且看起来很可靠,所以你应该不会有任何问题。
我很高兴听到这如何/是否对您有用。
PS:这是荷兰语的相同链接:http://www .jkp-ads.com/Articles/UndoWithVBA01NL.asp
Seems like it is possible after all
This can be done, but you'll have to write a pretty involved Undo handler.
Here's a link that well tell you exactly
how: http://www.jkp-ads.com/Articles/UndoWithVBA01.asp
Fortunatly the link has full sourcecode and it looks ironclad so you should have no problems.
I'll be happy to hear how/if this worked for you.
PS: here's the same link in Dutch: http://www.jkp-ads.com/Articles/UndoWithVBA01NL.asp