我有一个 VBA Word 宏,它打开一个 Word 文档,然后打开一个 Excel 文件,选择一个单元格引用,最后使用 Msgbox 显示一条消息。打开 Excel 文件后,我无法找到使 Word 可见的代码,以便用户可以查看 Msgbox 消息,而无需使用任务栏从 Excel 切换到 Word。我试过oWord.Visible = True了,但 VBA 给了我一个错误。任何提示表示赞赏。
请看下面的代码:
Sub Module_Test()
Dim oExcel As Object
Dim oWord_Doc as object
Dim wb_open as workbook
Set oExcel = New Excel.Application
str_Excel_Filename = "C:\Test\Excel_Template.xlsx"
Documents.Open ("C:\Test\Doc_to_process.docx")
Set oWord_Doc = activedocument
oExcel.Visible = True
oExcel.ScreenUpdating = True
oExcel.Workbooks.Open str_Excel_Filename
Set wb_open = activeworkbook
wb_open.ActiveSheet.range("a6").Select
' At this point Excel is visible. But the Msgbox statement below is not visible except when one switches to Word using the task bar. What statement do I put here to make Word visible?
Msgbox "Here is a message that should be visible when viewing the window containing the Doc_to_process.docx"
End Sub