Quantcast
Channel: Adobe Community: Message List - Acrobat SDK
Viewing all articles
Browse latest Browse all 10848

Re: With VBA in excel, how can I copy a pdf document (page by page into different worksheets)

$
0
0

Hello Test Screen Name,

I am making no headway and am hoping that you can offer some help?  This is my my code but I am copying the entire file each time.

 

Private Sub Sample_Pages()
'IAC objects
Dim PDFApp As CAcroApp
Dim pdfDoc As CAcroPDDoc
Dim pdfAVdoc As AcroAVDoc
Dim pdfPageView As AcroAVPageView
Dim pdfPage As AcroPDPage
Dim PDFPath As String
Dim numPages As Integer

'temporary hard coding of file name
PDFPath = "C:\PDF\Sample.pdf"

'Initialize Acrobat by creating App object
Set PDFApp = CreateObject("AcroExch.App")
Set pdfAVdoc = CreateObject("Acroexch.AVDoc")
Set pdfDoc = CreateObject("AcroExch.PDDoc")

' open the av and pd doc
If pdfAVdoc.Open(PDFPath, "") Then
    Set pdfDoc = pdfAVdoc.GetPDDoc
   
    numPages = pdfDoc.GetNumPages
    Set pdfPageView = pdfAVdoc.GetAVPageView
      
    For i = 1 To numPages
        Set pdfPage = pdfDoc.AcquirePage(i)
         
        SendKeys "{CLEAR}"   ' i would like to avoid the use of sendkeys but cannot work out  copytoclipboard method

        SendKeys ("a"), True
        SendKeys ("^c"), True
   
         Windows("Book1.xls").Activate
         Sheets.Add
         ActiveSheet.Range("H1").Select
         ActiveSheet.Paste
     Next i
Else
      MsgBox PDFPath & " - File not found"
      Exit Sub
End If

pdfAVdoc.Close (True)
pdfDoc.Close
PDFApp.Exit

End Sub


Viewing all articles
Browse latest Browse all 10848

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>