Foxit PDF SDK ActiveX

How to use Foxit PDF SDK ActiveX with Visual Basic

Basically, you have two options to use Foxit PDF SDK ActiveX component with Visual Basic. Both are described above:

Option A:

  • Open Excel or Access
  • Select DEVELOPER->Visual BasicNote: If you do not have the Developer tab. Go to File->Option->Customize Ribbon-> Check the Developer tab to add it
  • In the Microsoft Visual Basic for applications, select Tools->Reference->Browse…
  • 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.
  • Foxit ActiveX comes in both x64 and x86 ocx. Repeat step 4 to add the other .ocx to the project.
  • Go to DEVELOPER->Insert-> ActiveX Controls-> More Tools->choose FoxitPDFSDK Pro Control
  • Select the region in the Excel or Access Sheet which you want the control to appear
  • Go to the Visual Basic Editor
  • 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
  • Change the page in the code from “E:\foxit\SE\test.pdf” to an existing path on your machine.
  • Save and run it using the run button in Visual Basic Editor.

Option B:

  •  Open Excel or Access
  • 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
  • In the Microsoft Visual Basic for applications, select Tools->Reference->Browse…
  • 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.
  • Foxit ActiveX comes in both x64 and x86 ocx. Repeat step 4 to add the other .ocx to the project.
  • 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
  • Make changes to the code below to match the path of a PDF on your desktop:
    ret = Sheet1.FoxitPDFSDK
    1.OpenFile(“E:\foxit\SE\f20.pdf” , “”)
  • Run the code by pressing the play/run button.
    Note: Select the Object Browser Icon to see full list of features.

Updated on April 5, 2017

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: