Private Sub test3_Click()
Dim my_db As Database
Dim my_tb As Recordset
Dim str_path As String
Dim str_dotname As String
Dim str_DotPathAndName As String
Dim appWord As Word.Application
Dim doc As Document
Dim prps As Object
Set my_db = CurrentDb
Set my_tb = CurrentDb.OpenRecordset("班级姓名")
str_path = "C:\Users\wangcheng\Desktop\TEST2\"
str_dotname = "t模板.dot"
str_DotPathAndName = str_currentpath & str_dotname
Do While Not my_tb.EOF
'On Error GoTo ErrorHandler
Set appWord = CreateObject("Word.Application")
Set appWord = GetObject(, "Word.Application")
Set doc = appWord.Documents.Add(str_DotPathAandName)
Set prps = doc.CustomDocumentProperties
prps.Item("班级").value = my_tb.Fields("班级").Value
prps.Item("姓名").value = my_tb.Fields("姓名").Value