|
发表于 2017-5-11 21:23
|
显示全部楼层
本楼为最佳答案
本帖最后由 france723 于 2017-5-11 21:27 编辑
我设定的页名是"01", 自己改. 文字内容也自己改动
- Sub test()
- Dim y, ar, n
- With Sheets("01")
- y = .Range("a65536").End(xlUp).Row
- ar = .Range("a1:c" & y)
- End With
- For n = 2 To y
- Dim wordapp As Object, i
- Set wordapp = CreateObject("word.application")
- With wordapp
- .documents.Add
- With .Selection
- .TypeText Text:=" Notice"
- .TypeParagraph
- .TypeText Text:=ar(n, 1) & " hello, your house " & ar(n, 3) & " need to pay " & ar(n, 2) & " thank you"
- End With
- .activedocument.SaveAs Filename:=ThisWorkbook.Path & "" & ar(n, 1) & ".docx"
- End With
- wordapp.Quit
- Set wordapp = Nothing
- Next n
- End Sub
复制代码 |
|