如何在execl宏中启动WORD文档运行WORD宏?

发布网友 发布时间:2022-04-24 18:57

我来回答

1个回答

热心网友 时间:2022-05-01 13:41

Dim wrdApp As Object
Dim wrdDoc As Object

On Error GoTo myErr
Set wrdApp = GetObject(, "Word.Application") ‘有Word进程时
Set wrdDoc = wrdApp.Documents.Open("Word文件地址")
wrdApp.Visible = True '显示Word
wrdApp.Run "Word 宏名"

Set wrdDoc = Nothing
Set wrdApp = Nothing
Exit Sub

myErr:
Set wrdApp = CreateObject("Word.Application") ‘没有Word进程时
Set wrdDoc = wrdApp.Documents.Open("Word 文件地址")
wrdApp.Visible = True '显示Word
wrdApp.Run "Word 宏名"

Set wrdDoc = Nothing
Set wrdApp = Nothing

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com