PDF到Excel转换将每个pdf页面放在不同的工作表中 [英] PDF to Excel conversion putting each pdf page in a different worksheet

查看:331
本文介绍了PDF到Excel转换将每个pdf页面放在不同的工作表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am attempting to convert a pdf file (with 16 pages) to an excel file in order to run a program I already have in place in excel. I have a code that converts the pdf to excel already, but I would like the macro to put each separate page of the pdf file in a different worksheet in my excel file( currently it copies all of the pages and pastes page 1 of the pdf into a worksheet).

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

All of the pages have the same heading if that helps at all. My current code is included below, thanks in advance.

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


推荐答案

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

Try this. You should be able to make a loop and extract each pages of your PDF in different worksheet.

这篇关于PDF到Excel转换将每个pdf页面放在不同的工作表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆