Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).

New Forum | Previous | Next | (P-PDF) Developers

Topic: VB6 Run-time Error Problem
Conf: (P-PDF) Developers, Msg: 105547
From: mub2000
Date: 2/6/2004 06:50 PM

Hi every body in this group.

I have a VB application that doing a routine loop of searching string in (PDF) files located in a subdirectory then send the result of files contain this string into a grid.
This routine using (Java scrip Object) , the error description detail is :
-----Error start
The following error occured -2147417851 Automation Error The server threw An exception.
-----Error end
the code of the procedure that doing the search as the following:
---The Declarations are :
Option Explicit
Dim DocLimit As Long
Dim QueryClick As Boolean
Dim gApp As Acrobat.CAcroApp
Dim InputText As String
Dim gbStop As Boolean
Dim gPdDoc As Acrobat.CAcroPDDoc
Dim gAvDoc As Acrobat.CAcroAVDoc
Dim gPDFPath As String
Public PathOfsearch As String
-----End declarations
---Code Start:
Sub FindWordOnFile(Grid As MSFlexGrid, FileFullPath As String, FileDate As String, Pubname As String)
'local variables
Dim jso As Object
Dim x As Long
Dim nCount As Long
Dim I As Long, j As Long
Dim word As Variant
Dim result As Variant
Dim foundErr As Boolean
Dim nPages As Long, nWords As Long
Dim str As String
Dim rc As Integer
' get JavaScript Object
' note jso is related to PDDoc of a PDF,
Set jso = gPdDoc.GetJSObject
' count
nCount = 0
gbStop = False
' search for the text
If Not jso Is Nothing Then

' info
LabelInfo.Caption = "Search ... "

' total number of pages
nPages = jso.numPages

' Go through pages
For I = 0 To nPages - 1

' check each word in a page
nWords = jso.getPageNumWords(I)
For j = 0 To nWords - 1

' get a word
word = jso.getPageNthWord(I, j)
If VarType(word) = vbString Then

' compare the word with what the user wants

' result = StrComp(word, InputText, vbCompareText)
result = StrComp(word, InputText, vbTextCompare)
' if same
If result = 0 Then
nCount = nCount + 1
rc = jso.selectPageNthWord(I, j)

' info
LabelInfo.Caption = "# " & nCount & " found in page " & (I + 1)

' If MsgBox("The word is found: Count " & nCount & ". Continue?", vbYesNo) = vbNo Then
' GoTo TheEnd
' End If

' info
LabelInfo.Caption = "Search ... "

End If
End If
Next j
Next I

' summary

If nCount > 0 Then
LabelInfo.Caption = "Total found: " & nCount
Grid.Rows = Grid.Rows + 1
x = Grid.Rows - 1
With Grid
.Row = x
.Col = 1
.CellFontSize = 9
.CellAlignment = AlignmentSettings.flexAlignCenterCenter
.Text = Pubname
.Row = x
.Col = 2
.CellFontSize = 9
.CellAlignment = AlignmentSettings.flexAlignCenterCenter
.Text = FileDate
.Row = x
.Col = 3
.CellFontSize = 9
.CellAlignment = AlignmentSettings.flexAlignCenterCenter
.Text = CStr(nPages)
End With
Grid.TextMatrix(x, 0) = FileFullPath
' Grid.TextMatrix(X, 1) = Pubname
' Grid.TextMatrix(X, 2) = FileDate
' Grid.TextMatrix(X, 3) = CStr(nPages)
LabelInfo.Caption = "Not found in the document"
End If

Set jso = Nothing

End If
End Sub
---End code

So what Is the cause of this probelem and how we gonna solve it?

PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Five visions of a PDF Day

In the world of PDFs or as we like to say Planet (of) PDF, a year isn't a real PDF year without an intense few days of industry knowledge sharing.

May 15, 2018
Platinum Sponsor

Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.


Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.