Copying data from multiple pdf files

后端 未结 6 1149
太阳男子
太阳男子 2021-01-14 19:51

I have pdf files from which I would like to copy all the data to a column in a spreadsheet.

Here is the code I have. All it does is open the pdf, use control-a, then

6条回答
  •  没有蜡笔的小新
    2021-01-14 20:34

    BELOW CODE WILL COPY DATA FROM PDF & will PASTE IT IN WORD THEN COPY DATA FROM WORD AND THEN PASTE IT TO THE EXCEL .

    NOW Why I am copying data from pdf to word & then copying from word and pasting it to the excel because i want the data from the pdf in exact format to my excel sheet if i copy directly from pdf to excel it will paste the whole data from pdf into a single cell means even if i am having two columns or multiple rows it will paste all of my data into one column and that too in single cell but if i copy from word to excel it will retain its original format and two columns will get pasted as two columns only in excel.

    Private Sub CommandButton3_Click()  '(load pdf)
    
    
       Dim o As Variant
    Set appWord = CreateObject("Word.Application")
     o = Shell("C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe C:\Users\saurabh.ad.sharma\Desktop\Book1.pdf", vbNormalFocus)   'loading adobe reader & pdf file from their location
     Application.Wait (Now + TimeSerial(0, 0, 2))
       SendKeys ("^a")
    SendKeys ("^c")
     SendKeys "%{F4}"
    Application.Wait Now + TimeValue("00:00:01")
     Set appWord = CreateObject("Word.Application")
     appWord.Visible = True
     appWord.Documents.Add.Content.Paste
    With appWord
    
           .ActiveDocument.SaveAs Filename:=ThisWorkbook.Path & "\pdf" & ".docx", FileFormat:=wdocument   'saving word file in docx format
            .ActiveWindow.Close
            .Quit
        End With
    
    MsgBox " pdf is loaded "
    MsgBox " Paste to EXCEL "
    
        Set appWord = CreateObject("Word.Application")
         appWord.Visible = True
    
      appWord.Documents.Open "C:\Users\saurabh.ad.sharma\Desktop\pdf.docx" 'opening word document
          appWord.Selection.WholeStory
          appWord.Selection.Copy
       Set wkSheet = ActiveSheet
        wkSheet.Range("A1").Select
        wkSheet.Paste 'pasting to the excel file
    
    End Sub
    

提交回复
热议问题