在同一台计算机上更新 Word 文档时运行 .exe 文件

发布于 2024-09-05 05:27:33 字数 107 浏览 1 评论 0原文

我不知道这是否可行,但我需要执行以下操作。 当我在电脑上对 Word 文档进行更改(保存它并且日期每次都会更改)时,我希望在同一台计算机上运行 .exe 文件。有什么方法或第三方软件可以实现这一点吗?

i dont know if this is possible, but i need to do the following.
When i make changes to a word document on my pc (save it and the date changes everytime), I want a .exe file on the same computer to run. Is there any way or third party software, with which i can achieve this?

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

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

发布评论

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

评论(1

疯了 2024-09-12 05:27:33

在大多数情况下,最简单的方法可能是将下面的代码放入 VBA 模块中,无论是在 Word 的 Normal.dot 模板、另一个专用的全局模板中还是在特定文档中:

Option Explicit

Private Declare Function ShellExecute _
    Lib "shell32.dll" _
        Alias "ShellExecuteA" ( _
            ByVal Hwnd As Long, _
            ByVal lpOperation As String, _
            ByVal lpFile As String, _
            ByVal lpParameters As String, _
            ByVal lpDirectory As String, _
            ByVal nShowCmd As Long) _
As Long

Public Sub FileSave()

  ShellExecute 0, "open", "C:\Windows\System32\calc.exe", "", "", 0
  ActiveDocument.Save

End Sub

Probably the easiest way which will work under most circumstances is to put the code below inside a VBA module, either in Word's Normal.dot template, another dedicated global templated or in a specific document:

Option Explicit

Private Declare Function ShellExecute _
    Lib "shell32.dll" _
        Alias "ShellExecuteA" ( _
            ByVal Hwnd As Long, _
            ByVal lpOperation As String, _
            ByVal lpFile As String, _
            ByVal lpParameters As String, _
            ByVal lpDirectory As String, _
            ByVal nShowCmd As Long) _
As Long

Public Sub FileSave()

  ShellExecute 0, "open", "C:\Windows\System32\calc.exe", "", "", 0
  ActiveDocument.Save

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