web-dev-qa-db-ja.com

PDF各PDFページを異なるワークシートに配置するExcelへの変換

Excelに既に配置されているプログラムを実行するために、PDFファイル(16ページ)を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
5
Mike

this を試してください。ループを作成して、PDFの各ページを異なるワークシートに抽出できるはずです。