利用WORD模版,如何快速批量生成WORD文档
本帖最后由 bcrun 于 2013-10-21 10:59:01 编辑 作了个程序测试,发现错误提示5941
集合所要求的成员不存在
请老师帮忙看看
Private Sub Command1_Click()
Dim i As Long
Dim Report As Word.Document
Dim ApplicationWd As Word.Application
Set ApplicationWd = New Word.Application
' Set Report = ApplicationWd.Documents.Add(App.Path & "\text.doc")
For i = 1 To 50
SaveWord i, Report
Next i
Set Report = Nothing
ApplicationWd.Quit
End Sub
Private Function SaveWord(ByVal i As Long, ByVal TmpReport As Word.Document)
Dim Myrange As Range
Set Myrange = TmpReport.FormFields.Item("aaa").Range
Myrange.Text = Text1.Text
TmpReport.SaveAs (App.Path & "" & i & ".doc")
Set TmpReport = Nothing
Set Myrange = Nothing
End Function