2,462
社区成员
发帖
与我相关
我的任务
分享
Sub AAA()
Dim Ar(1 To 2000, 1 To 20)
Dim FilePath As String
Dim FileName As String
Dim Flag As Boolean
Dim S As String
Dim S1 As String
Dim N As Long
Dim I As Long
Dim Doc As Object
Set Doc = CreateObject("word.application")
Doc.DisplayAlerts = False
FilePath = ThisWorkbook.Path & "\"
FileName = Dir(FilePath & "*.DOC*")
Do Until Len(FileName) = 0
With Doc.Documents.Open(FilePath & FileName, False, True)
S = Replace(.Paragraphs(2).Range, Chr(13), "")
S1 = .TABLES(1).CELL(2, 2)
S1 = Replace(S1, Chr(7), "")
S1 = Replace(S1, Chr(13), "")
I = 2
Flag = False
Do Until S1 = ""
N = N + 1
Ar(N, 1) = Right(S, 10)
Ar(N, 2) = DatePart("WW", Ar(N, 1))
Ar(N, 3) = FileName
With .TABLES(1)
Ar(N, 4) = .CELL(I, 2).Range
Ar(N, 5) = .CELL(I, 3).Range
Ar(N, 6) = .CELL(I, 4).Range
Ar(N, 18) = .CELL(I, 1).Range
Ar(N, 20) = .CELL(5, 1).Range
Ar(N, 20) = Trim(Mid(Ar(N, 20), InStr(Ar(N, 20), ":") + 1))
End With
I = I + 1
S1 = .TABLES(1).CELL(I, 2)
S1 = Replace(S1, Chr(7), "")
S1 = Replace(S1, Chr(13), "")
Loop
.Close False
End With
FileName = Dir
Loop
Doc.Quit
Set Doc = Nothing
Application.ScreenUpdating = False
With Range("A3").Resize(N, 20)
.Value = Ar
.Replace Chr(7), "", xlPart
.Replace Chr(13), "", xlPart
End With
MsgBox "完成"
End Sub