给你段示例,你再接着完善你的:
Dim wdApp As Word.Application '定义WORD对象
Dim wdDoc As Word.Document '定义WORD文档对象
Dim wkSheet As Worksheet '定工作表对象
Dim I As Long
'实例化WORD对象
Set wdApp = New Word.Application
'创建WORD文档
Set wdDoc = wdApp.Documents.Add
'给工作表变量赋值
Set wkSheet = ThisWorkbook.Sheets("WriteWord")
'保存新创建的WORD文档
wdDoc.SaveAs ThisWorkbook.Path & "\test.docx"
wdDoc.Close '关闭新创建的WORD文档
With wdApp
'打开WORD文档
.Documents.Open ThisWorkbook.Path & "\test.docx"
'循环将工作表中的记录转换为WORD文档内容
For I = 2 To wkSheet.Range("a1048576").End(xlUp).Row
'题头内容
.Selection.TypeText "亲爱的" & Trim(wkSheet.Cells(I, 1).Value)
'根据性别确定人物称呼
If wkSheet.Cells(I, 2).Value = "男" Then
.Selection.TypeText "先生:"
Else
.Selection.TypeText "女士:"
.... .....
sf