可以用下列代码批量写入:
Sub test()
Filename = Application.GetOpenFilename _
(FileFilter:="word Files (*.doc),*.doc," _
& "Word Files (*.docx),*docx", _
Title:="请选择需要填充数据的word文件")
If Filename = False Then Exit Sub
arr = Sheets(1).[a1].CurrentRegion
Set wdapp = CreateObject("word.application")
wdapp.Visible = True
With wdapp.Documents.Open(Filename)
.Tables(1).Columns(1).Select
For Each cel In .Parent.Selection.Cells
n = n + 1
If cel.Range.Text = Chr(13) & Chr(7) Then
n = n - 1
Exit For
End If
Next
If UBound(arr) = n Then GoTo over
.Tables(1).Rows(n).Select
.Parent.Selection.InsertRowsBelow UBound(arr) - n
For i = n + 1 To UBound(arr)
.Tables(1).Cell(i, 1).Range = i - 1
.Tables(1).Cell(i, 2).Range = arr(i, 1)
.Tables(1).Cell(i, 3).Range = Format$(arr(i, 6), "percent")
Next
over:
.Save
.Close wdSaveChanges
wdapp.Quit
End With
End Sub