|
楼主 |
发表于 2016-7-27 10:42
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 lsc900707 于 2016-7-27 10:44 编辑
Sub 汇总()
[A2:AI250].ClearContents
Application.ScreenUpdating = False
Dim cPath$, cFile$, str$, i%, arr(1 To 500, 1 To 35)
Dim wordD As Word.Document
Dim wordapp As Object
cPath = ThisWorkbook.Path & "\"
cFile = Dir(cPath & "*.doc?")
Set wordapp = CreateObject("Word.Application")
Do While cFile <> ""
Set wordD = wordapp.Documents.Open(cPath & cFile)
i = i + 1
With wordD.Tables(1)
arr(i, 2) = Replace(.Cell(2, 2).Range.Text, Chr(7), "")
arr(i, 3) = Replace(.Cell(2, 4).Range.Text, Chr(7), "")
arr(i, 4) = Replace(.Cell(2, 6).Range.Text, Chr(7), "")
arr(i, 5) = Replace(.Cell(3, 2).Range.Text, Chr(7), "")
arr(i, 6) = Replace(.Cell(3, 4).Range.Text, Chr(7), "")
arr(i, 7) = Replace(.Cell(3, 6).Range.Text, Chr(7), "")
arr(i, 8) = Replace(.Cell(4, 2).Range.Text, Chr(7), "")
arr(i, 9) = Replace(.Cell(4, 4).Range.Text, Chr(7), "")
arr(i, 10) = Replace(.Cell(5, 2).Range.Text, Chr(7), "")
arr(i, 11) = Replace(.Cell(5, 4).Range.Text, Chr(7), "")
arr(i, 12) = Replace(.Cell(6, 3).Range.Text, Chr(7), "")
arr(i, 13) = Replace(.Cell(6, 5).Range.Text, Chr(7), "")
arr(i, 14) = Replace(.Cell(7, 3).Range.Text, Chr(7), "")
arr(i, 15) = Replace(.Cell(7, 5).Range.Text, Chr(7), "")
arr(i, 16) = Replace(.Cell(8, 2).Range.Text, Chr(7), "")
arr(i, 17) = Replace(.Cell(8, 4).Range.Text, Chr(7), "")
arr(i, 18) = Replace(.Cell(9, 2).Range.Text, Chr(7), "")
arr(i, 19) = Replace(.Cell(9, 4).Range.Text, Chr(7), "")
arr(i, 20) = Replace(.Cell(9, 6).Range.Text, Chr(7), "")
arr(i, 21) = Replace(.Cell(10, 2).Range.Text, Chr(7), "")
arr(i, 22) = Replace(.Cell(13, 2).Range.Text, Chr(7), "")
arr(i, 23) = Replace(.Cell(13, 3).Range.Text, Chr(7), "")
arr(i, 24) = Replace(.Cell(14, 2).Range.Text, Chr(7), "")
arr(i, 25) = Replace(.Cell(14, 3).Range.Text, Chr(7), "")
arr(i, 26) = Replace(.Cell(14, 4).Range.Text, Chr(7), "")
arr(i, 27) = Replace(.Cell(15, 2).Range.Text, Chr(7), "")
arr(i, 28) = Replace(.Cell(15, 3).Range.Text, Chr(7), "")
arr(i, 29) = Replace(.Cell(15, 4).Range.Text, Chr(7), "")
arr(i, 30) = Replace(.Cell(16, 2).Range.Text, Chr(7), "")
arr(i, 31) = Replace(.Cell(16, 3).Range.Text, Chr(7), "")
arr(i, 32) = Replace(.Cell(16, 4).Range.Text, Chr(7), "")
arr(i, 33) = Replace(.Cell(19, 1).Range.Text, Chr(7), "") & Replace(.Cell(19, 2).Range.Text, Chr(7), "") _
& Replace(.Cell(19, 3).Range.Text, Chr(7), "") & Replace(.Cell(19, 4).Range.Text, Chr(7), "") & Chr(13) _
& Replace(.Cell(20, 1).Range.Text, Chr(7), "") & Replace(.Cell(20, 2).Range.Text, Chr(7), "") _
& Replace(.Cell(20, 3).Range.Text, Chr(7), "") & Replace(.Cell(20, 4).Range.Text, Chr(7), "")
arr(i, 34) = Replace(.Cell(23, 1).Range.Text, Chr(7), "") & Replace(.Cell(23, 2).Range.Text, Chr(7), "") _
& Replace(.Cell(23, 3).Range.Text, Chr(7), "") & Replace(.Cell(23, 4).Range.Text, Chr(7), "") _
& Replace(.Cell(23, 5).Range.Text, Chr(7), "") & Replace(.Cell(23, 6).Range.Text, Chr(7), "") & Chr(13) _
& Replace(.Cell(24, 1).Range.Text, Chr(7), "") & Replace(.Cell(24, 2).Range.Text, Chr(7), "") _
& Replace(.Cell(24, 3).Range.Text, Chr(7), "") & Replace(.Cell(24, 4).Range.Text, Chr(7), "") _
& Replace(.Cell(24, 5).Range.Text, Chr(7), "") & Replace(.Cell(24, 6).Range.Text, Chr(7), "")
arr(i, 35) = Replace(.Cell(29, 1).Range.Text, Chr(7), "")
End With
wordD.Close
cFile = Dir
Loop
Set wordD = Nothing
wordapp.Quit
Sheet1.Range("A2").Resize(i, 35) = arr
Application.ScreenUpdating = True
End Sub
亲,终于依样画葫芦画出来了,但是为什么只有第一个的信息?还有33和34列可以简化代码吗?
|
|