Copy all text from a PDF and copy in Excel












1















I have read a lot of topics about this, but nothing works.
I want to take a PDF already existing



PDFPath = "C:UsersDesktopTest PDF.pdf"


Select all, copy it
then select Excel, and paste everything in TxT format from A2.



Maybe I have problems with Library ?
I have Acrobat Reader DC.



C:Program Files (x86)AdobeAcrobat Reader DCAcroRd32.exe


I already put 2 libraries :




  • Adobe Acrobat Browser Control Type Library 1.0

  • Adobe Reader File Preview Type Library


.



    Sub pdf_to_excel_adobe()

Dim myWorksheet As Worksheet
Dim adobeReaderPath As String
Dim pathAndFileName As String
Dim shellPathName As String

Set myWorksheet = ActiveWorkbook.Worksheets("Adobe Reader")


adobeReaderPath = "C:Program Files (x86)AdobeAcrobat Reader DCReaderAcroRd32.exe"
pathAndFileName = "C:UsersStagiaireDesktopTest PDF.pdf"
shellPathName = adobeReaderPath & " """ & pathAndFileName & """"

Call Shell( _
pathname:=shellPathName, _
windowstyle:=vbNormalFocus)

Application.Wait Now + TimeValue("0:00:03")

SendKeys "%vpc"
SendKeys "^a"
SendKeys "^c"


Application.Wait Now + TimeValue("0:00:30")

With myWorksheet
.Range("A2").Select
.PasteSpecial Format:="Text"
End With

Call Shell("TaskKill /F /IM AcroRd32.exe", vbHide)


End Sub


It say that there is a problem with Selection from Range at this line :



.Range("A2").Select


EDIT :



I changed with that :



With myWorksheet
.Activate
.Range("A2").Select
.PasteSpecial Format:="Text"
End With


But it say now that I have the same problem with PasteSpecial…



EDIT :



Now changed with that and it is Working !!!



' activate this wokbook
Windows("Test pdf import.xlsm").Activate
ActiveWorkbook.Worksheets("Adobe Reader").Activate
Range("A2").Select
ActiveSheet.Paste


The problem were Something about the select/activate fonction I think...










share|improve this question

























  • There's a bunch of information missing - notably, what's the code you're using to open and read the file?

    – BruceWayne
    Nov 14 '18 at 16:22






  • 1





    As of Office 2013, pdf files can be opened with Word, perhaps that makes life easier?

    – jkpieterse
    Nov 14 '18 at 16:39











  • Yes, but it's the same problem… I want to do all by excel and have all the text of the PDF in a sheet in my workbook.

    – babou
    Nov 14 '18 at 16:57











  • If your PDF is saved with an image file, opening a PDF is not enough. You will need OCR software too.

    – Karlomanio
    Nov 14 '18 at 18:57











  • No it's not, I can select the text in the PDF

    – babou
    Nov 15 '18 at 8:13
















1















I have read a lot of topics about this, but nothing works.
I want to take a PDF already existing



PDFPath = "C:UsersDesktopTest PDF.pdf"


Select all, copy it
then select Excel, and paste everything in TxT format from A2.



Maybe I have problems with Library ?
I have Acrobat Reader DC.



C:Program Files (x86)AdobeAcrobat Reader DCAcroRd32.exe


I already put 2 libraries :




  • Adobe Acrobat Browser Control Type Library 1.0

  • Adobe Reader File Preview Type Library


.



    Sub pdf_to_excel_adobe()

Dim myWorksheet As Worksheet
Dim adobeReaderPath As String
Dim pathAndFileName As String
Dim shellPathName As String

Set myWorksheet = ActiveWorkbook.Worksheets("Adobe Reader")


adobeReaderPath = "C:Program Files (x86)AdobeAcrobat Reader DCReaderAcroRd32.exe"
pathAndFileName = "C:UsersStagiaireDesktopTest PDF.pdf"
shellPathName = adobeReaderPath & " """ & pathAndFileName & """"

Call Shell( _
pathname:=shellPathName, _
windowstyle:=vbNormalFocus)

Application.Wait Now + TimeValue("0:00:03")

SendKeys "%vpc"
SendKeys "^a"
SendKeys "^c"


Application.Wait Now + TimeValue("0:00:30")

With myWorksheet
.Range("A2").Select
.PasteSpecial Format:="Text"
End With

Call Shell("TaskKill /F /IM AcroRd32.exe", vbHide)


End Sub


It say that there is a problem with Selection from Range at this line :



.Range("A2").Select


EDIT :



I changed with that :



With myWorksheet
.Activate
.Range("A2").Select
.PasteSpecial Format:="Text"
End With


But it say now that I have the same problem with PasteSpecial…



EDIT :



Now changed with that and it is Working !!!



' activate this wokbook
Windows("Test pdf import.xlsm").Activate
ActiveWorkbook.Worksheets("Adobe Reader").Activate
Range("A2").Select
ActiveSheet.Paste


The problem were Something about the select/activate fonction I think...










share|improve this question

























  • There's a bunch of information missing - notably, what's the code you're using to open and read the file?

    – BruceWayne
    Nov 14 '18 at 16:22






  • 1





    As of Office 2013, pdf files can be opened with Word, perhaps that makes life easier?

    – jkpieterse
    Nov 14 '18 at 16:39











  • Yes, but it's the same problem… I want to do all by excel and have all the text of the PDF in a sheet in my workbook.

    – babou
    Nov 14 '18 at 16:57











  • If your PDF is saved with an image file, opening a PDF is not enough. You will need OCR software too.

    – Karlomanio
    Nov 14 '18 at 18:57











  • No it's not, I can select the text in the PDF

    – babou
    Nov 15 '18 at 8:13














1












1








1








I have read a lot of topics about this, but nothing works.
I want to take a PDF already existing



PDFPath = "C:UsersDesktopTest PDF.pdf"


Select all, copy it
then select Excel, and paste everything in TxT format from A2.



Maybe I have problems with Library ?
I have Acrobat Reader DC.



C:Program Files (x86)AdobeAcrobat Reader DCAcroRd32.exe


I already put 2 libraries :




  • Adobe Acrobat Browser Control Type Library 1.0

  • Adobe Reader File Preview Type Library


.



    Sub pdf_to_excel_adobe()

Dim myWorksheet As Worksheet
Dim adobeReaderPath As String
Dim pathAndFileName As String
Dim shellPathName As String

Set myWorksheet = ActiveWorkbook.Worksheets("Adobe Reader")


adobeReaderPath = "C:Program Files (x86)AdobeAcrobat Reader DCReaderAcroRd32.exe"
pathAndFileName = "C:UsersStagiaireDesktopTest PDF.pdf"
shellPathName = adobeReaderPath & " """ & pathAndFileName & """"

Call Shell( _
pathname:=shellPathName, _
windowstyle:=vbNormalFocus)

Application.Wait Now + TimeValue("0:00:03")

SendKeys "%vpc"
SendKeys "^a"
SendKeys "^c"


Application.Wait Now + TimeValue("0:00:30")

With myWorksheet
.Range("A2").Select
.PasteSpecial Format:="Text"
End With

Call Shell("TaskKill /F /IM AcroRd32.exe", vbHide)


End Sub


It say that there is a problem with Selection from Range at this line :



.Range("A2").Select


EDIT :



I changed with that :



With myWorksheet
.Activate
.Range("A2").Select
.PasteSpecial Format:="Text"
End With


But it say now that I have the same problem with PasteSpecial…



EDIT :



Now changed with that and it is Working !!!



' activate this wokbook
Windows("Test pdf import.xlsm").Activate
ActiveWorkbook.Worksheets("Adobe Reader").Activate
Range("A2").Select
ActiveSheet.Paste


The problem were Something about the select/activate fonction I think...










share|improve this question
















I have read a lot of topics about this, but nothing works.
I want to take a PDF already existing



PDFPath = "C:UsersDesktopTest PDF.pdf"


Select all, copy it
then select Excel, and paste everything in TxT format from A2.



Maybe I have problems with Library ?
I have Acrobat Reader DC.



C:Program Files (x86)AdobeAcrobat Reader DCAcroRd32.exe


I already put 2 libraries :




  • Adobe Acrobat Browser Control Type Library 1.0

  • Adobe Reader File Preview Type Library


.



    Sub pdf_to_excel_adobe()

Dim myWorksheet As Worksheet
Dim adobeReaderPath As String
Dim pathAndFileName As String
Dim shellPathName As String

Set myWorksheet = ActiveWorkbook.Worksheets("Adobe Reader")


adobeReaderPath = "C:Program Files (x86)AdobeAcrobat Reader DCReaderAcroRd32.exe"
pathAndFileName = "C:UsersStagiaireDesktopTest PDF.pdf"
shellPathName = adobeReaderPath & " """ & pathAndFileName & """"

Call Shell( _
pathname:=shellPathName, _
windowstyle:=vbNormalFocus)

Application.Wait Now + TimeValue("0:00:03")

SendKeys "%vpc"
SendKeys "^a"
SendKeys "^c"


Application.Wait Now + TimeValue("0:00:30")

With myWorksheet
.Range("A2").Select
.PasteSpecial Format:="Text"
End With

Call Shell("TaskKill /F /IM AcroRd32.exe", vbHide)


End Sub


It say that there is a problem with Selection from Range at this line :



.Range("A2").Select


EDIT :



I changed with that :



With myWorksheet
.Activate
.Range("A2").Select
.PasteSpecial Format:="Text"
End With


But it say now that I have the same problem with PasteSpecial…



EDIT :



Now changed with that and it is Working !!!



' activate this wokbook
Windows("Test pdf import.xlsm").Activate
ActiveWorkbook.Worksheets("Adobe Reader").Activate
Range("A2").Select
ActiveSheet.Paste


The problem were Something about the select/activate fonction I think...







excel vba excel-vba excel-2016






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 8:31







babou

















asked Nov 14 '18 at 16:11









baboubabou

13711




13711













  • There's a bunch of information missing - notably, what's the code you're using to open and read the file?

    – BruceWayne
    Nov 14 '18 at 16:22






  • 1





    As of Office 2013, pdf files can be opened with Word, perhaps that makes life easier?

    – jkpieterse
    Nov 14 '18 at 16:39











  • Yes, but it's the same problem… I want to do all by excel and have all the text of the PDF in a sheet in my workbook.

    – babou
    Nov 14 '18 at 16:57











  • If your PDF is saved with an image file, opening a PDF is not enough. You will need OCR software too.

    – Karlomanio
    Nov 14 '18 at 18:57











  • No it's not, I can select the text in the PDF

    – babou
    Nov 15 '18 at 8:13



















  • There's a bunch of information missing - notably, what's the code you're using to open and read the file?

    – BruceWayne
    Nov 14 '18 at 16:22






  • 1





    As of Office 2013, pdf files can be opened with Word, perhaps that makes life easier?

    – jkpieterse
    Nov 14 '18 at 16:39











  • Yes, but it's the same problem… I want to do all by excel and have all the text of the PDF in a sheet in my workbook.

    – babou
    Nov 14 '18 at 16:57











  • If your PDF is saved with an image file, opening a PDF is not enough. You will need OCR software too.

    – Karlomanio
    Nov 14 '18 at 18:57











  • No it's not, I can select the text in the PDF

    – babou
    Nov 15 '18 at 8:13

















There's a bunch of information missing - notably, what's the code you're using to open and read the file?

– BruceWayne
Nov 14 '18 at 16:22





There's a bunch of information missing - notably, what's the code you're using to open and read the file?

– BruceWayne
Nov 14 '18 at 16:22




1




1





As of Office 2013, pdf files can be opened with Word, perhaps that makes life easier?

– jkpieterse
Nov 14 '18 at 16:39





As of Office 2013, pdf files can be opened with Word, perhaps that makes life easier?

– jkpieterse
Nov 14 '18 at 16:39













Yes, but it's the same problem… I want to do all by excel and have all the text of the PDF in a sheet in my workbook.

– babou
Nov 14 '18 at 16:57





Yes, but it's the same problem… I want to do all by excel and have all the text of the PDF in a sheet in my workbook.

– babou
Nov 14 '18 at 16:57













If your PDF is saved with an image file, opening a PDF is not enough. You will need OCR software too.

– Karlomanio
Nov 14 '18 at 18:57





If your PDF is saved with an image file, opening a PDF is not enough. You will need OCR software too.

– Karlomanio
Nov 14 '18 at 18:57













No it's not, I can select the text in the PDF

– babou
Nov 15 '18 at 8:13





No it's not, I can select the text in the PDF

– babou
Nov 15 '18 at 8:13












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53304445%2fcopy-all-text-from-a-pdf-and-copy-in-excel%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53304445%2fcopy-all-text-from-a-pdf-and-copy-in-excel%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python