|
Option Explicit
Sub A()
Dim appWD, doc As Object, arr, i%, j%, M%, ran
Set appWD = CreateObject("Word.Application")
arr = [B1].CurrentRegion
For i = 2 To UBound(arr)
Set doc = appWD.Documents.Open(ThisWorkbook.Path & "\" & arr(i, 2))
appWD.Visible = 0
appWD.Selection.HomeKey unit:=6
Set ran = appWD.Application.ActiveDocument.Range
For j = 3 To 5
With ran.Find
.ClearFormatting
.Text = arr(1, j)
.Forward = 1
.Wrap = 1
If .Execute Then
M = ran.Start
appWD.ActiveDocument.Range(M, M).Select
appWD.Selection.MoveDown unit:=4, Extend:=1
appWD.Selection.Text = arr(1, j) & ":" & arr(i, j) & Chr(13)
End If
End With
Next
appWD.ActiveDocument.Tables(1).Cell(7, 2).Range.Text = arr(i, 6)
appWD.ActiveDocument.Tables(1).Cell(7, 4).Range.Text = arr(i, 7)
appWD.ActiveDocument.Tables(1).Cell(15, 4).Range.Text = arr(i, 8)
appWD.ActiveDocument.Tables(1).Cell(16, 2).Range.Text = arr(i, 9)
appWD.ActiveDocument.Tables(4).Cell(5, 2).Range.Text = arr(i, 10)
appWD.ActiveDocument.Tables(4).Cell(7, 2).Range.Text = arr(i, 11)
doc.Close
Next
appWD.Quit
End Sub
|
评分
-
3
查看全部评分
-
|