如何使用命令行将宏文件(以前导出为 .bas 文件)导入到 Microsoft Word?

发布于 2024-08-29 21:33:13 字数 301 浏览 2 评论 0原文

我正在编写一个命令行程序,其中有一个步骤需要替换Word 文件中的文本。替换任务是使用Word宏来完成的。

我现在需要做的是从命令行调用这个宏。目前,我们可以通过使用“winword.exe”的/mMacroName参数来完成此操作,即\winword.exe /mMacroName。但这需要宏已经作为全局宏可用。

由于我需要在另一台计算机上运行该程序,因此我需要以编程方式导入上述替换宏......而且我不知道如何执行此操作。

I'm writing a command-line program that has a step in which I need to replace text in a Word file. The replacing task is accomplished using Word macro.

What I need to do now is to call this macro from command-line. At the moment we can do this by using the /mMacroName parameter of 'winword.exe', i.e. <path-to-msoffice>\winword.exe /mMacroName. But this needs the macro to be already available as a global macro.

Since I need to run the program on another computer, I need to import the above replacing macro programmatically... and I don't know how to do this.

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

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

发布评论

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

评论(1

溺孤伤于心 2024-09-05 21:33:13

使用 VBScript 添加宏是一种选择。您可以在以下相关问题中找到开始使用的示例:

使用 VBScript 删除 MS Word 宏

Adding the macro using VBScript would be an option. You can find a sample to get started in the following related question:

Remove MS Word macro using VBScript

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