试试这样
With Tables("XXXX")
For i As Integer = .TopPosition To .BottomPosition '选定行
Dim dr As Row = .Rows(i)
Dim xm = dr("姓名")
Dim fl As String = ProjectPath & "Reports\" & xm & ".doc"
Dim tm As String = ProjectPath & "Attachments\表.doc" '指定模板文件
Dim wrt As New WordReport(Tables("XXXX"),tm,fl) '定义一个WordReport
wrt.BuildOne(dr) '生成报表
wrt.Quit() '显示报表
Next
MessageBox.Show("文件已生成")
End With