统计WORD页码字数

使用界面图
模快一:
Sub WORD文件统计()
Dim wapp, m, k, word1
Dim numc As Integer, numpic As Integer, numpage As Integer, numtable As Integer, filename As String
Dim rowend As Integer, i%
With ThisWorkbook.Sheets(1)
.Range(“a2:e100000”).Clear
Set wapp = CreateObject(“Word.Application”)
m = Application.GetOpenFilename(Title:=“打开文件”, MultiSelect:=True, filefilter:=“WORD文件(.doc),.doc”)
'判断是否选中文件
If Not IsArray(m) Then
Application.ScreenUpdating = True
Exit Sub
End If

For Each k In m
   Set word1 = wapp.Documents.Open(k)
    wapp.Windows(1).Visible = True
    .Range("a" & i + 2) = word1.Name '文件名
    .Range("b" & i + 2) = word1.BuiltinDocumentProperties(wdPropertyWords) '字数
    .Range("c" & i + 2) = word1.Range.Information(wdNumberOfPagesInDocument) '页数
    .Range("d" & i + 2) = word1.InlineShapes.Count '图片数
    .Range("e" & i + 2) = word1.tables.Count '表格数
    i = i + 1
    word1.Close False
    Set word1 = Nothing
Next

End With
wapp.Quit
Set wapp = Nothing
MsgBox “done”, , “统计完毕”
End Sub

模块二
Sub 文件改名()
Dim X%, Y%

X = [A65536].End(xlUp).Row
On Error Resume Next
For Y = 2 To X
If Cells(Y, 2) <> “” Then
Name ActiveWorkbook.Path & “” & Cells(Y, 1) As ActiveWorkbook.Path & “” & Cells(Y, 2)
End If
Next
MsgBox “完成”
End Sub

模块三
Sub 列出所有文件名()
Dim A%
A = [A65536].End(xlUp).Row
If A > 1 Then: Range(“A2:A” & A).ClearContents
Dim xlsFile As String, XX As String
XX = Range(“C2”).Text
xlsFile = Dir(ActiveWorkbook.Path & “” & XX)
Do
If InStr(1, xlsFile, “操作表”) = 0 Then
Cells(([A65536].End(xlUp).Row + 1), 1) = xlsFile

End If
xlsFile = Dir
Loop Until Len(xlsFile) = 0
MsgBox “完成”
End Sub

VBA结构图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

想做个高级码农

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值