操作方法:从 C# Ribbon Addin 运行现有的 Word VBA 宏
背景:我有一组广泛的专用 VBA 宏,在 Word 中用于文档格式设置。在Word 2003 中,这些宏是从自定义工具栏激活的。我最近过渡到 Word 2007,希望能够从使用 VS 2010 创建的新 Word 功能区运行这些现有的 VBA 宏。我已经创建了一个功能区;但是,我无法弄清楚如何从新的功能区按钮调用现有的宏。
问题:如何从 C# Word 插件调用存储在 .dotm 模板中的现有 VBA 宏?
任何帮助将不胜感激。
Background: I have an extensive set of specialized VBA macros used in Word for document formatting purposes. In Word 2003, these macros were activated from a customized toolbar. I have recently transitioned to Word 2007 and would like to be able to run these existing VBA macros from a new Word Ribbon created with VS 2010. I have created a Ribbon; however, I cannot figure out how to call the existing macros from the new Ribbon buttons.
Question: How do I call the existing VBA macros, which are stored in a .dotm template, from the C# Word Add-in?
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MS 知识库文章 306683 中描述的技术 - 特别是函数
RunMacro
在那里定义 - 应该允许您从 C# 代码中调用 VBA 宏:您定义一个函数RunMacro
,然后像这样调用您的宏:
或者
oApp
是 < code>Word.Application 对象,我确信该对象在 Word 加载项中的某个位置可用。The technique described in MS KB article 306683 -- in particular, function
RunMacro
defined there -- should allow you to call a VBA macro from within C# code: You define a functionRunMacro
and then call your macro like this:
or
oApp
is theWord.Application
object, which I'm sure is available somewhere in a Word add-in.