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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading PDF files via Excel 2007 VBA 1

Status
Not open for further replies.

phudgens

Technical User
Jul 8, 2004
117
US
I know this is likely a stupid question, but does anyone know of a way (3rd party software?) to read a PDF file on the fly via an Excel 2007 VBA program? I realize this will likely require conversion to some other file type.

Thanks,
Paul Hudgens
Denver
 

I don't think it is 'a stupid question' :)

To open any file: create this sub:

Code:
Public Sub OpenDocument(strDocPath As String)

Dim G As Long
G = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & strDocPath, vbNormalFocus)
    
End Sub

To use it, just pass the path and file name:

Code:
Call OpenDocument("C:\Folder\SomeFile.pdf")

If your pdf is asociated with Acrobat Reader, it will show your pdf in it. You can open Excel file in Excel, Word in Word, text in Notepad, you name it.

Have fun.

---- Andy
 
Many apologies, but what I was hoping to do was convert the PDF file to some readable format (TXT,DOC,XLS) that I could then read via my VBA program. I know that the formatting would be different, but I can search for specific strings and likely find what I need. 3rd party programs exist that can convert PDF files, but they can't be invoked from within VBA.

Thanks,
Paul Hudgens
 
The full version of Acrobat has an Export feature with options for Word documents, HTML. XML, plain text.

 
I was hoping to do the conversion, and the reading, from within the VBA program.
 
The OP was trying to easily convert a PDF file into an excel VBA program. The OP wanted to be able to read the text from the PDF and paste in the excel VBA program.
 
Phudgens - there is some ambiguity in your requriements:
read a pdf on the fly with VBA
convert the PDF file to some readable format (TXT,DOC,XLS) that I could then read via my VBA program
I was hoping to do the conversion, and the reading, from within the VBA program.

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top