Open a PDF using VBA in Excel

后端 未结 5 1882
南笙
南笙 2020-12-10 15:18

I\'m trying to open all appropriate PDFs found in the same directory as my Excel workbook using VBA. I\'ve added the Adobe Acrobat xx.x Type Library reference to the projec

5条回答
  •  既然无缘
    2020-12-10 15:57

    Here is a simplified version of this script to copy a pdf into a XL file.

    
    Sub CopyOnePDFtoExcel()
    
        Dim ws As Worksheet
        Dim PDF_path As String
    
        PDF_path = "C:\Users\...\Documents\This-File.pdf"
    
    
        'open the pdf file
        ActiveWorkbook.FollowHyperlink PDF_path
    
        SendKeys "^a", True
        SendKeys "^c"
    
        Call Shell("TaskKill /F /IM AcroRd32.exe", vbHide)
    
        Application.ScreenUpdating = False
    
        Set ws = ThisWorkbook.Sheets("Sheet1")
    
        ws.Activate
        ws.Range("A1").ClearContents
        ws.Range("A1").Select
        ws.Paste
    
        Application.ScreenUpdating = True
    
    End Sub
    
    

提交回复
热议问题