|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 182197315 于 2016-12-7 20:38 编辑
程序里加一句代码
On Error Resume Next
Sub 提取信息()
Range("A1").CurrentRegion.Offset(1, 0).ClearContents
Cells.Borders.LineStyle = xlNone
Application.ScreenUpdating = False
Dim wordD As Word.Document
Dim wordapp As Object
Dim cPath$, cFile$, i%, arr()
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
ReDim Preserve arr(1 To 4, 1 To i)
With wordD
arr(1, i) = Replace(Replace(.Paragraphs(18).Range.Text, Chr(7), ""), Chr(13), "")
arr(3, i) = Replace(Replace(.Paragraphs(20).Range.Text, Chr(7), ""), Chr(13), "")
arr(2, i) = Replace(Replace(.Paragraphs(44).Range.Text, Chr(7), ""), Chr(13), "")
arr(4, i) = Replace(Replace(.Paragraphs(82).Range.Text, Chr(7), ""), Chr(13), "")
End With
wordD.Close
cFile = Dir
Loop
Set wordD = Nothing
wordapp.Quit
Range("a2").Resize(i, 4).Value = Application.Transpose(arr)
Range("A1:D" & i + 1).Borders.LineStyle = xlContinuous
Application.ScreenUpdating = True
End Sub
|
|