Announcement

Collapse
No announcement yet.

Executing a programmatic search in Foxit PDF using Excel VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Executing a programmatic search in Foxit PDF using Excel VBA

    This is likely the wrong forum for this question, but I'm hoping to find a way to programmatically execute a search in Foxit using Excel VBA. I am successfully opening the file using:

    "ShellExecute 0, “Open”, “C:\MyFile”, “”, “”, vbNormalNoFocus"

    but now need a way to do a search in the opened file. Does anyone have any ideas?

    Thanks,

    Paul Hudgens
    Denver

  • #2
    You can register Foxit ActiveX and do a search with that. You can get an evaluation package of Foxit PDF Active X 5.2 at this link: https://www.foxitsoftware.com/produc...X-Professional. Once you get that package, you should have two Foxit ActiveX control .ocx file. You can then follow the instructions below to register the Foxit ActiveX controls and create a project in VBA. Once you create a VBA project and get it running you can run ActiveX interfaces for searching. The main search function is called FindFrist, you can find that interfaces on page label 66 of http://cdn01.foxitsoftware.com/pub/f...X52_Manual.pdf.

    How to use Foxit ActiveX with Visual Basic Application
    Option A:
    1. Open Excel or Access
    2. Select DEVELOPER->Visual Basic
    Note: If you do not have the Developer tab. Go to File->Option->Customize Ribbon-> Check the Developer tab to add it
    1. In the Microsoft Visual Basic for applications, select Tools->Reference->Browse…
    2. Browse to the folder where you have the Foxit ActiveX’s OCX located at and select the .ocx and press open, then press okay to add the reference.
    Note: You may need to change the file type to .ocx to see the ocx file.
    1. Foxit ActiveX comes in both x64 and x86 ocx. Repeat step 4 to add the other .ocx to the project.
    2. Go to DEVELOPER->Insert-> ActiveX Controls-> More Tools->choose FoxitPDFSDK Pro Control
    3. Select the region in the Excel or Access Sheet which you want the control to appear
    4. Go to the Visual Basic Editor
    5. Copy the following code to the “ThisWorkbook” of the project.

    Sub OpenFile()
    Dim ret
    ret = Sheet1.FoxitPDFSDK1.OpenFile("E:\foxit\SE\test.pdf ", "")
    Sheet1.FoxitPDFSDK1.FindFirst(“myTextString”, False, False)
    Sheet1.FoxitPDFSDK1.GoToPage (0)
    End Sub
    9. Change the page in the code from "E:\foxit\SE\test.pdf" to an existing path on your machine.
    10. Save and run it using the run button in Visual Basic Editor.


    Option B:
    1. Open Excel or Access
    2. Select DEVELOPER->Visual Basic
    Note: If you do not have the Developer tab. Go to File->Option->Customize Ribbon-> Check the Developer tab to add it
    3. In the Microsoft Visual Basic for applications, select Tools->Reference->Browse…
    4. Browse to the folder where you have the Foxit ActiveX’s OCX located at and select the .ocx and press open, then press okay to add the reference.
    Note: You may need to change the file type to .ocx to see the ocx file.
    5. Foxit ActiveX comes in both x64 and x86 ocx. Repeat step 4 to add the other .ocx to the project.
    6. In the Project View, select ThisWorkbook and copy and paste the code below.
    Sub AddFoxitPDFSDKPro()
    Dim Target As Range
    Set Target = Cells(1, 4)
    Set WSheet = ThisWorkbook.Worksheets("Sheet1")
    Set MyPDFSDK = WSheet.OLEObjects.Add(ClassType:="Foxit.FoxitPDFSD KProCtrl.5", Link:=False, DisplayAsIcon:=False, Left:=Target.Left, Top:=Target.Top, Width:=400, Height:= 600)
    End Sub

    Sub OpenFile()
    Dim ret
    ret = Sheet1.FoxitPDFSDK1.OpenFile("E:\foxit\SE\f20.pdf" , "")
    Sheet1.FoxitPDFSDK1.GoToPage (2)
    End Sub
    7. Make changes to the code below to match the path of a PDF on your desktop
    ret = Sheet1.FoxitPDFSDK1.OpenFile("E:\foxit\SE\f20.pdf" , "")
    8. Run the code by pressing the play/run button
    Note: Select the Object Browser Icon to see full list of features.

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎