|
发表于 2018-12-23 08:16
来自手机
|
显示全部楼层
芸谣 发表于 2018-12-23 03:19
啊,想实现这个功能,但是完全不懂VB啊,要疯了
Sub W_TO_E_提取文字及表格数据_参考()
Cells.Clear
Cells.NumberFormatLocal = "@"
Dim 外档数组, 结果数组(1 To 60000, 1 To 1)
Application.ScreenUpdating = False: Application.DisplayAlerts = False
Set wd = CreateObject("word.Application")
路径 = ThisWorkbook.Path & "\"
外档 = Dir(路径 & "*.doc*")
Do While 外档 <> ""
计数器 = 0
文档计数器 = 文档计数器 + 1
With wd.Documents.Open(路径 & 外档)
.Range.ListFormat.ConvertNumbersToText
外档数组 = Split(.Range.Text, Chr(13))
.Close False
End With
Cells(1, 文档计数器) = Split(外档, ".")(0)
For i = 0 To UBound(外档数组)
If 外档数组(i) <> "" And Len(外档数组(i)) Then
计数器 = 计数器 + 1
结果数组(计数器, 文档计数器) = Replace(外档数组(i), "", "")
End If
Next
外档 = Dir
Loop
wd.Quit
Range("a2").Resize(计数器, 1) = 结果数组
Application.DisplayAlerts = True: Application.ScreenUpdating = True
MsgBox "ok"
End Sub |
|