terminatorgenx
New Member
- Joined
- Dec 14, 2012
- Messages
- 1
Hi,
I have an Excel-2010 file which contains students unique admission number in column-A.
Everytime I click in any cell in column-A, the code below finds the student in the PDF file.
Need help with the following:
Everytime I click on a cell in column-A, it should find the student admission number in pdf and take me to that page (note every student has one page).
I have an Excel-2010 file which contains students unique admission number in column-A.
Everytime I click in any cell in column-A, the code below finds the student in the PDF file.
Need help with the following:
Everytime I click on a cell in column-A, it should find the student admission number in pdf and take me to that page (note every student has one page).
Code:
Sub AcrobatFindText2()
'variables
Dim Resp 'For message box responses
Dim gPDFPath As String
Dim sText As String 'String to search for
Dim sStr As String 'Message string
Dim foundText As Integer 'Holds return value from "FindText" method
'hard coding for a PDF to open, it can be changed when needed.
gPDFPath = "Example.pdf"
'Initialize Acrobat by creating App object
Set gApp = CreateObject("AcroExch.App", "")
gApp.Hide
'Set AVDoc object
Set gAvDoc = CreateObject("AcroExch.AVDoc")
' open the PDF
If gAvDoc.Open(gPDFPath, "") Then
sText = "AB9991442" [U][I][B]'Students unique admission number[/B][/I][/U]
'FindText params: StringToSearchFor, caseSensitive (1 or 0), WholeWords (1 or 0), 'ResetSearchToBeginOfDocument (1 or 0)
foundText = gAvDoc.FindText(sText, 1, 0, 1) 'Returns -1 if found, 0 otherwise
Else ' if failed, show error message
Resp = MsgBox("Cannot open" & gPDFPath, vbOKOnly)
End If
If foundText = -1 Then
'compose a message
sStr = "Found " & sText
Resp = MsgBox(sStr, vbOKOnly)
Else ' if failed, 'show error message
Resp = MsgBox("Cannot find" & sText, vbOKOnly)
End If
gApp.Show
gAvDoc.BringToFront
End Sub