6,216
社区成员




粘贴一下“循环遍历文件夹及子文件夹”的打开方法(更改单个 WORD 文件打开方式查找你的信息可也——楼主必须制作附件样稿多来几个文件,因为表格和文字提取方法不一样):
Sub doc2txt()
On Error Resume Next
Dim fd As FileDialog, i As Long, doc As Document, p As String
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
If fd.Show = -1 Then p = fd.SelectedItems(1) Else Exit Sub
Set fd = Nothing
If MsgBox("Are you sure to convert? (" & p & ")", vbYesNo + vbExclamation, "doc2txt") = vbNo Then Exit Sub
With Application.FileSearch
.LookIn = p
.SearchSubFolders = True
.FileName = "*.doc"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Set doc = Documents.Open(FileName:=.FoundFiles(i))
doc.SaveAs FileName:=Left(doc.FullName, Len(doc.FullName) - 4) & ".txt", FileFormat:=wdFormatText
ActiveDocument.Close
Next i
MsgBox "Complete! There were " & .FoundFiles.Count & " file(s) converted.", vbOKOnly + vbExclamation, "doc2txt"
Else
MsgBox "There were no files found.", vbOKOnly + vbCritical, "doc2txt"
End If
End With
End Sub