|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
按照你这要求肯定要掉坑里,哈哈
Sub 填写()
Application.ScreenUpdating = False
Dim myword, myPath$, myfile, mydoc, s, i, n, arr, wdapp
myPath = ThisWorkbook.Path & "\"
Set wdapp = VBA.CreateObject("Word.Application")
arr = [a1].CurrentRegion
For i = 2 To UBound(arr)
FileCopy myPath & "模板.docx", myPath & arr(i, 7) & ".docx"
With wdapp.Documents.Open(myPath & arr(i, 7) & ".docx")
.Tables(2).Cell(2, 2).Range = arr(i, 2)
.Tables(2).Cell(2, 5).Range = arr(i, 3)
.Tables(2).Cell(2, 6).Range = arr(i, 4)
.Tables(2).Cell(2, 7).Range = arr(i, 8)
.Tables(2).Cell(2, 8).Range = arr(i, 9)
.Tables(2).Cell(2, 9).Range = arr(i, 10)
.Close True
End With
Next
wdapp.Quit
Set wdapp = Nothing
MsgBox "填写完毕!", , "报告"
End Sub
|
|