05.12.2022, 16:58
Hello, can anyone help to remake following VBA to repeat the process (open a new PDF file, copy, paste into a new text file)
as many PDF files contains a folder?
Thanks in advance!
as many PDF files contains a folder?
Thanks in advance!
Code:
Public Sub Copy_and_Paste_From_PDF_File2()
Dim AdobeApp As String
Dim PDFfile As String
Dim StartAdobe
ActiveSheet.Cells.Clear
AdobeApp = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" 'Acrobat Reader
PDFfile = "C:\path\to\Invoice 123.pdf"
StartAdobe = Shell(Q(AdobeApp) & " " & Q(PDFfile), 1)
'Wait 3 seconds to allow PDF to open
Application.Wait DateAdd("s", 3, Now)
'Select All and Copy from PDF
SendKeys "^a^c", True
'Wait 5 seconds to allow Select All and Copy to finish
Application.Wait DateAdd("s", 5, Now)
'Paste into Excel
AppActivate Application.Caption
ActiveSheet.Range("A1").Select
SendKeys "^v", True
End Sub
Private Function Q(text As String) As String
Q = Chr(34) & text & Chr(34)
End Function