如何以编程方式将工具栏按钮(和 OnClick 处理程序)添加到 Excel
如何以编程方式将工具栏(其上带有按钮)添加到 Excel (2002 年或之后)?
单击按钮时,我想要一个处理程序来创建我的 COM 对象并调用它的方法?
How do I programmatically add a toolbar (with buttons on it) to Excel
(2002 or later)?
When the button is clicked I want a handler to create my COM
object and call a method on it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是应该适用于但不包括 Excel 2007 版本的基础,它具有完全不同的界面。
这位于您的 ThisWorkbook 模块中:
这可以位于同一个模块中,也可以位于单独的模块中,您可以选择,尽管我更喜欢将其放在自己的模块中,这样可以更明显。 您不需要 OnClick,当您创建按钮时,按钮会被告知要调用哪个例程。
This is the basis for something that should work on versions up to but not including Excel 2007, which has a completely different interface.
This goes in your ThisWorkbook module:
And this can go in the same module or a separate one, your choice, although I prefer to put it in its own module where it can be more visible. YOu shouldn't need an OnClick, the button is told what routine to call when you create the button.
您可以编写一个 Excel 加载项,用您的按钮和 COM 调用代码创建工具栏 ,然后将您创建的 .xla 文件拖放到用户的 XLStart 文件夹中。
You could write an Excel add-in that creates a toolbar with your button and COM-calling code, then drop the .xla file you create in the user's XLStart folder.