|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- '函数名称:ExtractPDFpages
- '函数功能:调用Acrobat提取pdf的单个页面并输出到指定目录(命名规则为[原文件名 - p#.pdf])
- '参数:
- '1. sPDFfile;原始PDF文件的完整路径
- '2. sOutputFolder;提出的PDF页面的保存目录
- '注意:需要在装有【Acrobat Professional】软件的电脑上运行
- Sub ExtractPDFpages(sPDFfile As String, sOutputFolder As String)
- Dim pdf, pdfSource
- Dim iPageCount As Integer
- Dim sFileName As String
-
-
- sFileName = Mid(sPDFfile, InStrRev(sPDFfile, "") + 1)
- sFileName = Left(sFileName, InStrRev(sFileName, ".") - 1)
-
-
- Set pdf = CreateObject("AcroExch.PDDoc")
- Set pdfSource = CreateObject("AcroExch.PDDoc")
- pdfSource.Open sPDFfile
- iPageCount = pdfSource.GetNumPages
-
- If Right(sOutputFolder, 1) <> "" Then
- sOutputFolder = sOutputFolder & ""
- End If
- For i = 0 To iPageCount - 1
- pdf.Create
- pdf.InsertPages -1, pdfSource, i, 1, 0
- pdf.Save 1, sOutputFolder & sFileName & "-p" & i + 1 & ".pdf"
- pdf.Close
-
- Next
- pdfSource.Close
- Set pdf = Nothing
- Set pdfSource = Nothing
- End Sub
- '测试代码
- Sub Test()
- ExtractPDFpages "d:\Guide.pdf", "d:\output"
- '提取d:\Guide.pdf,并保存为:d:\output\Guide-p1.pdf、d:\output\Guide-p2.pdf、d:\output\Guide-p3.pdf……
- End Sub
复制代码 |
评分
-
5
查看全部评分
-
|