|
楼主 |
发表于 2013-12-4 13:23
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
已经解决。冻大师版主的代码:
Sub Macro1()
- Sub PatchWord()
- Dim i As Integer
- For i = 2 To Range("a65536").End(xlUp).Row
- FileCopy ThisWorkbook.Path & "\word模板.docx", ThisWorkbook.Path & "" & Cells(i, 1) & ".docx"
- Next
- End Sub
复制代码 赵刚版主的代码:
- Sub Macro1()
- Dim p$, f$, f2, i&, arr
- arr = [a1].CurrentRegion
- p = ThisWorkbook.Path & ""
- f = p & "word模板.docx"
- For i = 2 To UBound(arr)
- FileCopy f, p & arr(i, 1) & ".docx"
- Next
- MsgBox "ok"
- End Sub
复制代码 佛山小老鼠版主代码:
- Sub 生成word()
- Dim MyWord, NewDoc, WordName
- Application.DisplayAlerts = False
- Set MyWord = CreateObject("Word.Application")
- MyPath = ThisWorkbook.Path & ""
- For x = 1 To Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row
- WordName = Sheets(1).Cells(x, 1)
- Set NewDoc = MyWord.Documents.Add
- With NewDoc
- .Activate
- .SaveAs Filename:=MyPath & WordName & ".docx"
- .Close
- End With
- Next x
- MyWord.Quit
- Set MyWord = Nothing
- Application.DisplayAlerts = True
- End Sub
复制代码 注意:佛山小老鼠版主的代码只是批量生成空白word文件,没有复制word文档模板的内容的。
感谢三位版主的支持。
|
|