【问题标题】:PDF to Excel conversion putting each pdf page in a different worksheetPDF 到 Excel 转换将每个 pdf 页面放在不同的工作表中
【发布时间】:2013-07-09 14:36:19
【问题描述】:

我正在尝试将 pdf 文件(16 页)转换为 excel 文件,以便运行我在 excel 中已有的程序。我已经有一个将pdf转换为excel的代码,但是我希望宏将pdf文件的每个单独页面放在我的excel文件中的不同工作表中(目前它复制所有页面并粘贴pdf的第1页到工作表中)。

如果有帮助的话,所有页面都有相同的标题。我当前的代码包含在下面,在此先感谢。

Private Sub CommandButton1_Click()
 'Declare Variable(s)
Dim appAA As Acrobat.CAcroApp, docPDF As Acrobat.CAcroPDDoc
Dim strFileName As String, intNOP As Integer, arrI As Variant
Dim intC As Integer, intR As Integer, intBeg As Integer, intEnd As Integer

'Initialize Variables
Set appAA = CreateObject("AcroExch.App"): Set docPDF = CreateObject("AcroExch.PDDoc")

'Set PDF FileName  
strFileName = "C:\Documents and Settings\Michael Palkovitz\My Documents\Test\EC Operations Budget February FY13.pdf"

'Read PDF File
docPDF.Open (strFileName)

'Extract Number of Pages From PDF File
intNOP = docPDF.GetNumPages

'Select First Data Cell
Range("A1").Select

'Open PDF File
ActiveWorkbook.FollowHyperlink strFileName, , True

'Loop Through All PDF File Pages
For intC = 1 To intNOP
'Go To Page Number
SendKeys ("+^n" & intC & "{ENTER}")

'Select All Data In The PDF File's Active Page
SendKeys ("^a"), True

'Right-Click Mouse
SendKeys ("+{F10}"), True

'Copy Data As Table
SendKeys ("c"), True

'Minimize Adobe Window
SendKeys ("%n"), True

'Paste Data In This Workbook's Worksheet
ActiveSheet.Paste

'Select Next Paste Cell
Range("A" & Range("A1").SpecialCells(xlLastCell).Row + 2).Select

'Maximize Adobe Window
SendKeys ("%x")
Next intC

'Close Adobe File and Window
SendKeys ("^w"), True

'Empty Object Variables
Set appAA = Nothing: Set docPDF = Nothing

'Select First Cell
Range("A1").Select
end sub

【问题讨论】:

    标签: vba excel pdf-conversion


    【解决方案1】:

    试试this。您应该能够循环并在不同的工作表中提取 PDF 的每一页。

    【讨论】:

    • 感谢您的帮助...代码运行没有错误,但在打开 pdf 时...我收到“文件名、目录名或卷标语法不正确”消息。我的 pdf文件路径如下 PDFPath = ThisWorkbook.Path & "\" & "C:\Documents and Settings\Michael Palkovitz\My Documents\Test\EC Operations Budget February FY13.pdf"
    • 更新..我得到了你打开文档的代码,只需要复制和粘贴即可。
    猜你喜欢
    • 1970-01-01
    • 2018-11-15
    • 2016-03-23
    • 1970-01-01
    • 2021-10-31
    • 2021-08-20
    • 1970-01-01
    • 2018-11-25
    • 1970-01-01
    相关资源
    最近更新 更多