求助大神!如果提取一个文件夹中多个word文本的名字、页数。
有100个文件,如何批量提取所有文件的文件名、每个文件页数,求助大神!
2023-03-10 09:10
程序代码:
Option Explicit
Sub 扫描WORD文件()
Dim fPath$, fName$, i&, wApp As Object
'先打开一个WORD进程
Set wApp = CreateObject("Word.Application")
wApp.Visible = True '调试的时候可以看见WORD打开、关闭,发布的时候可以注释此行
'开始扫描文件
fPath = "i:\Temp\exp\" '指定文件夹,注意以\结尾
fName = Dir(fPath & "*.doc?")
i = ActiveSheet.UsedRange.Rows.Count '保存在当前工作的行
While fName <> ""
i = i + 1
Cells(i, 1) = fName 'A列文件名
With wApp.Documents.Open(fPath & fName)
Cells(i, 2) = .BuiltinDocumentProperties(14) 'B列页数
Cells(i, 3) = .BuiltinDocumentProperties(30) 'C列字数
.Close
End With
fName = Dir
Wend
wApp.Quit
End Sub
2023-03-10 10:13
2023-03-14 10:18