|
Sub pdfcount()
Dim filename As String
Dim Match, Str$, P%
FileToOpen = Application.GetOpenFilename("PDF文件(*.PDF),*.PDF", , "Please select the files...", , True)
If IsArray(FileToOpen) = 0 Then
'MsgBox "没有选择文件"
MsgBox "No files are selected!"
WS1.Unprotect
GoTo ErrorHandler
End If
For i2 = 1 To UBound(FileToOpen)
userfilename = FileToOpen(i2)
With CreateObject("scripting.filesystemobject").opentextfile(FileToOpen(i2))
Str = .readall
.Close
End With
P = 0
With CreateObject("vbscript.regexp")
.Global = True
.MultiLine = True
.Pattern = "\/Count ([\d]+)"
If .test(sstr) Then
For Each Match In .Execute(sstr)
If Val(Match.submatches(0)) > P Then P = Val(Match.submatches(0))
Next Match
End If
End With
MsgBox (P)
Cells(i2, 2).Value = P
Next i2
ErrorHandler:
End Sub
请各位老师帮忙完善下..谢谢
|
|