Windows Vista Forums

Script to read information inside a pdf file

  1. #1


    Alex St-Pierre Guest

    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

  2. #2


    Tom Lavedas Guest

    Re: Script to read information inside a pdf file

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

    > 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


Script to read information inside a pdf file
Similar Threads
Thread Forum
Free Inside information about the Latest Games and Gaming. 00015 Vista Games
Free Inside information about the Latest Games and Gaming. 85862 Vista Games
batch file / script to replace information VB Script
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