|
Option Explicit
Sub TEST()
Dim ar, br, i&, j&, r&, wdApp As Word.Application, strFileName$, strPath$
Application.ScreenUpdating = False
ReDim ar(1 To 2, 3)
br = Array(2, 4, 6, 8)
[A1].CurrentRegion.Offset(1).ClearContents
r = 1
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err <> 0 Then
Set wdApp = New Word.Application
End If
strPath = ThisWorkbook.Path & "\word\"
strFileName = Dir(strPath & "*.doc*")
Do Until strFileName = ""
With wdApp.documents.Open(strPath & strFileName)
With .tables(1)
For j = 0 To UBound(br)
ar(1, j) = Left(.Range.Cells(br(j)).Range.Text, Len(.Range.Cells(br(j)).Range.Text) - 2)
ar(2, j) = .Range.Cells(br(j)).Range.Font.Color
Next j
End With
.Close False
End With
r = r + 1
For j = 0 To UBound(ar, 2)
Cells(r, j + 1).Value = ar(1, j)
Cells(r, j + 1).Font.Color = ar(2, j)
Next j
strFileName = Dir
Loop
If Err <> 0 Then wdApp.Quit
Set wdApp = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
2
查看全部评分
-
|