|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub Limonet()
Dim WSHShell As Object, pdfFile$, RegExp As Object, Arr As Variant, i%, Brr(1 To 2) As Variant, j%, S$
Set WSHShell = CreateObject("WScript.Shell")
Set RegExp = CreateObject("vbscript.regexp")
RegExp.Global = True
pdfFile = ThisWorkbook.Path & "\中国中学生心理健康评定量表.pdf"
WSHShell.Run """" & ThisWorkbook.Path & "\pdftotext.exe"" -enc UTF-8 """ & pdfFile & """", 0, True
Arr = Range("A1:B1")
With CreateObject("ADODB.Stream")
.Type = 2: .Mode = 3: .Open
.LoadFromFile Replace(pdfFile, ".pdf", ".txt")
.Charset = "UTF-8": .Position = 2
S = .ReadText
For i = 1 To UBound(Arr, 2)
RegExp.Pattern = Arr(1, i) & ": (.*?)\s"
Brr(i) = RegExp.Replace(RegExp.Execute(S)(0), "$1")
Next i
.Close
End With
Range("A2").Resize(1, 2) = Brr
Kill Replace(pdfFile, ".pdf", ".txt")
End Sub |
评分
-
2
查看全部评分
-
|