如何在文件打开后立即运行宏?
我想从外部数据源(Excel)“预填充”它。我知道如何填写文档,但希望宏自动运行
答案 0 :(得分:3)
使用Document.Open
事件。您需要将Document_Open()
子文件放在文件的ThisDocument
类模块中。 Example from MSDN:
Private Sub Document_Open()
MsgBox "This document is copyrighted."
End Sub
或在您的情况下像
Private Sub Document_Open()
Call PreFillDoc
End Sub
只有在宏已经启用的情况下才会运行。