Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Script to read information inside a pdf file

Reply
 
Old 10-07-2009   #1 (permalink)
Alex St-Pierre


 
 

Script to read information inside a pdf file

Hi !
I use the following VBA programmation to complete a pdf form (using
SendKeys). Once the form is completed, the users can make modifications.
After the form has been modified, the user return in Excel and save the pdf
parameters. Is there a way to catch the selection content of a pdf file? When
the PDF document is activated, the command Application.SendKeys send the
value in the PDF document but Application.Selection doesn't return the PDF
selection. Any idea?

Actual VBA code to modify a pdf document:
Dim myIE As Object
Dim dReturnValue As Double
Set myIE = CreateObject("InternetExplorer.Application")
myIE.navigate "http:\\... \file.pdf 'Open the pdf
myIE.Visible = True
dReturnValue = Shell("IEXPLORER.EXE", vbNormalFocus)
AppActivate dReturnValue 'Activate the pdf
Application.SendKeys "{TAB}", True
Application.SendKeys "TEXTVALUE1", True
Application.SendKeys "{TAB}", True
Application.SendKeys "TEXTVALUE2", True
etc.
I would like something that do the same steps but record the selection in
each pdf cell's like:
'Save PDF information
AppActivate dReturnValue 'Activate the .pdf
Application.ReturnToTheBeginningOfTheFile (Can be done using Shift-Tab...)
Application.SendKeys "{TAB}", True
vInformation = Application.Selection 'This doesn't word (???)
Thisworkbook.Sheets("Sheet1").Cells(1,1) = vInformation
AppActivate dReturnValue 'Activate PDF
Application.SendKeys "{TAB}", True
vInformation = Application.Selection 'Read the contents of the box #2
Thisworkbook.Sheets("Sheet1").Cells(2,1) = vInformation
etc.

Thank's a lot!
Alex

--
Alex St-Pierre

My System SpecsSystem Spec
Old 10-07-2009   #2 (permalink)
Tom Lavedas


 
 

Re: Script to read information inside a pdf file

On Oct 7, 11:46*am, Alex St-Pierre
<AlexStPie...@newsgroup> wrote:
Quote:

> Hi !
> I use the following VBA programmation to complete a pdf form (using
> SendKeys). Once the form is completed, the users can make modifications.
> After the form has been modified, the user return in Excel and save the pdf
> parameters. Is there a way to catch the selection content of a pdf file? When
> the PDF document is activated, the command Application.SendKeys send the
> value in the PDF document but Application.Selection doesn't return the PDF
> selection. Any idea?
>
> Actual VBA code to modify a pdf document:
> Dim myIE As Object
> Dim dReturnValue As Double
> Set myIE = CreateObject("InternetExplorer.Application")
> myIE.navigate "http:\\... \file.pdf 'Open the pdf
> myIE.Visible = True
> dReturnValue = Shell("IEXPLORER.EXE", vbNormalFocus)
> AppActivate dReturnValue 'Activate the pdf
> Application.SendKeys "{TAB}", True
> Application.SendKeys "TEXTVALUE1", True
> Application.SendKeys "{TAB}", True
> Application.SendKeys "TEXTVALUE2", True
> etc.
> I would like something that do the same steps but record the selection in
> each pdf cell's like:
> 'Save PDF information
> AppActivate dReturnValue 'Activate the .pdf
> Application.ReturnToTheBeginningOfTheFile (Can be done using Shift-Tab...)
> Application.SendKeys "{TAB}", True
> vInformation = Application.Selection 'This doesn't word (???)
> Thisworkbook.Sheets("Sheet1").Cells(1,1) = vInformation
> AppActivate dReturnValue 'Activate PDF
> Application.SendKeys "{TAB}", True
> vInformation = Application.Selection 'Read the contents of the box #2
> Thisworkbook.Sheets("Sheet1").Cells(2,1) = vInformation
> etc.
>
> Thank's a lot!
> Alex
>
> --
> Alex St-Pierre
Try something like ...

AppActivate dReturnValue 'Activate the .pdf
Application.ReturnToTheBeginningOfTheFile (Can be done using Shift-
Tab...)
For i = 1 To nTextBoxes
GetText i, 1
Next
End Sub

Sub GetText(nRow, nCol)
Application.SendKeys "{TAB}^c", True ' Copies form data
ThisWorkbook.Sheets("Sheet1").Paste _
ThisWorkbook.Sheets("Sheet1").Cells(nRow, nCol)
End Sub

_____________________
Tom Lavedas
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
batch file / script to replace information VB Script
How can I resolve %WINDIR% inside a PowerShell script? PowerShell
Question: The clock in vista can not synchronize - read inside please Vista performance & maintenance
change permission on all files inside a folder or hundreds of file inside a folder Vista security
System information inside, help on reintall of Vista requested Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46