Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert PDF file to text

hermanlaksko

Programmer
Aug 26, 2001
944
DK
Is there any vba code to convert PDF files into txt file - without using acrobat reader?

I have searched the net but have, so far, come up empty handed, all seem to need adope acrobar.
Thank you all in advance.
 
If you're starting from Excel you can control the Word object have VBA open the PDF. Once in Word you can save the document in numerous file formats.
 
Adobe has an add-in that converts PDF to multiple different formats, including excel, word, text, etc. Yes, you need to have Adobe, the free web version accessible at a minimum. The only other ways, I can think of off the top of my head are...

1. If the PDF file contains the text, meaning open and unsecured, where you can extract the text from the file itself. Otherwise, it is usually secured or an image.

2. In the days of old, we would print the PDF to TIFF then OCR it and save the results into a text file or DB.

3. As suggested above, you can create an instance of Word and use it to do what you want. (A fairly current version of Word.)

or you can go the long way around as I have described.


Good Luck
 
Thank you all.
I will give word an extra try :)

I had hoped for some vba code, so if any of you have some surplus code in your library, that just is in the way I will happily take it of your shoulders :cool:
wishing you all a happy easter :)
 
In Word VBA:
Code:
Sub test()
Dim wdDoc As Document
Application.DisplayAlerts = wdAlertsNone
Set wdDoc = Documents.Open(FileName:="PathAndFileName.pdf", AddToRecentFiles:=False)
wdDoc.SaveAs2 FileName:="PathAndFileName.txt", FileFormat:=wdFormatText, AddToRecentFiles:=False
wdDoc.Close Savechanges:=False
End Sub
If Word displays a warning about conversion, open any 'pdf' document in Word first, tick 'do not show this message', re-run the code.
 

Part and Inventory Search

Sponsor

Back
Top