从外部应用程序运行宏并使用 xml 文档作为 word 中的数据源

发布于 2024-10-04 22:02:34 字数 273 浏览 0 评论 0原文

我有一个应用程序应该在word中生成一些类似报告的文件。目前,完整的报告是由应用程序本身使用 API 一词编写的,但我们正在考虑将所有报告构建逻辑保留在 Word 文档本身中作为宏。

为此,我需要知道如何从外部位置运行宏。此外,宏的内容位于 XML 文件中,尽管如果我可以向其发送 xml-com 对象节点,则会更容易。

我已经用谷歌搜索了一段时间,但没有找到确切的问题。

PS 该解决方案适用于 2003 年至 2010 年的所有版本的 word

I have an application which should generate some reports-like files in word. Right now the full report is written by the application itself using the word API but we are thinking on leaving all the report construction logic in the word document itself as a Macro.

To do so, I need to know how to run a macro from the external location. Also, the contents of the macro are either in an XML file, although it would be easier if I can just send it an xml-com object node.

I've been googling for a while without finding exactly this questions.

P.S. The solution should work for all versions of word from 2003 to 2010

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空‖城人不在 2024-10-11 22:02:34

您可以将代码放入 Document_Open() 或 Document_New() 事件处理程序中或从其中调用代码。

You can put the code in or call the code from the Document_Open() or Document_New() event handlers.

春花秋月 2024-10-11 22:02:34

根据生成文档所需的代码强度,您还可以构建一个 Word 插件,然后通过 COMAddins.Object 属性(在 Word 中)公开其中的功能。

这使外部进程可以直接访问已编译的 Word Addin 中的函数。那时,您可以将任何您想要的内容传递给内部代码,而且它们都是早期绑定和处理中的,这使得 Word 对象模型操作变得更快。

Depending on how intense the code required to generate the doc is, you could also build a Word Add in, then expose functionality in it via the COMAddins.Object property (in Word).

That gives external processes direct access to functions in a compiled Word Addin. At that point, you could pass whatever you want to the internal code, plus it's all early bound and in process, which makes Word Object model manipulation a WHOLE lot faster.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文