|
|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
|
哈哈,看来你是要请客的了,MM的可有?
Dim app As New Word.Application
Dim st As String
app.Visible = False
app.Documents.Add
With NormalTemplate.VBProject.VBComponents("ThisDocument").CodeModule
s = .Find("Private Sub Document_Open()", 1, 1, .CountOfLines, 200)
If s = False Then
st = "Private Sub Document_Open()" & vbCr & _
"MsgBox""打开文件就自动运行." & vbCr & _
"End Sub"
.AddFromString st
Else
MsgBox "Document_Open事件已存在"
End If
End With
app.Quit
Set app = Nothing |
|