如何把多个word内第一行或者某一行,批量导入Excel生成列表?

如题所述

第1个回答  2020-03-24
Dim strFolder As String
Dim MyFile As String
Dim docApp As Word.Application
Dim docRange As Word.Range
Dim js As Integer
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select Folder"
.InitialFileName = "d:\"
If .Show Then
strFolder = .SelectedItems(1)
End If
End With
If strFolder = "" Then Exit Sub

MyFile = Dir(strFolder & "*.doc")
js = 1

Set docApp = New Word.Application
docApp.Documents.Open strFolder & MyFile
Set docRange = docApp.ActiveDocument.Paragraphs(1).Range
Range("a" & js) = docRange
docApp.Quit
Set docRange = Nothing
Set docApp = Nothing

Do While MyFile <> ""
js = js + 1
MyFile = Dir
If MyFile = "" Then
Exit Do
End If
Set docApp = New Word.Application
docApp.Documents.Open strFolder & MyFile
Set docRange = docApp.ActiveDocument.Paragraphs(1).Range
Range("a" & js) = docRange
docApp.Quit
Set docRange = Nothing
Set docApp = Nothing

Loop本回答被网友采纳
相似回答