xxsomethingx
11-24-2010, 01:42 PM
Hello,
I'm trying to create a macro to read PDF's from a file but I cannot seem to figure out why it's giving me this error. I work at a corporation where security is overly-done(access-wise) so i was thinking that would be the reason why this is giving me this error.
What can anyone tell me about this error? Will I not be able to create this macro due to security on the computers here? Or am I just not instantiating correctly?
Sub test()
Dim AcroApp As CAcroApp
Dim AcroAVDoc As CAcroAVDoc
Dim AcroPDDoc As CAcroPDDoc
Dim AcroHiliteList As CAcroHiliteList
Dim AcroTextSelect As CAcroPDTextSelect
Dim PageNumber, PageContent, Content, i, j
**This is where it's erroring out**Set AcroApp = CreateObject("AcroExch.App")
Set AcroAVDoc = CreateObject("AcroExch.AVDoc")
If AcroAVDoc.Open("I:\DOC001.pdf", vbNull) <> True Then
Exit Sub
End If
Set AcroAVDoc = AcroApp.GetActiveDoc
Set AcroPDDoc = AcroAVDoc.GetPDDoc
For i = 0 To AcroPDDoc.GetNumPages - 1
Set PageNumber = AcroPDDoc.AcquirePage(i)
Set PageContent = CreateObject("AcroExch.HiliteList")
If PageContent.Add(0, 9000) <> True Then
Exit Sub
End If
Set AcroTextSelect = PageNumber.CreatePageHilite(PageContent)
For j = 0 To AcroTextSelect.GetNumText - 1
Content = Content & AcroTextSelect.GetText(j)
Next j
Next i
AcroAVDoc.Close True
AcroApp.Exit
Set AcroDoc = Nothing
Set AcroApp = Nothing
End Sub
I'm trying to create a macro to read PDF's from a file but I cannot seem to figure out why it's giving me this error. I work at a corporation where security is overly-done(access-wise) so i was thinking that would be the reason why this is giving me this error.
What can anyone tell me about this error? Will I not be able to create this macro due to security on the computers here? Or am I just not instantiating correctly?
Sub test()
Dim AcroApp As CAcroApp
Dim AcroAVDoc As CAcroAVDoc
Dim AcroPDDoc As CAcroPDDoc
Dim AcroHiliteList As CAcroHiliteList
Dim AcroTextSelect As CAcroPDTextSelect
Dim PageNumber, PageContent, Content, i, j
**This is where it's erroring out**Set AcroApp = CreateObject("AcroExch.App")
Set AcroAVDoc = CreateObject("AcroExch.AVDoc")
If AcroAVDoc.Open("I:\DOC001.pdf", vbNull) <> True Then
Exit Sub
End If
Set AcroAVDoc = AcroApp.GetActiveDoc
Set AcroPDDoc = AcroAVDoc.GetPDDoc
For i = 0 To AcroPDDoc.GetNumPages - 1
Set PageNumber = AcroPDDoc.AcquirePage(i)
Set PageContent = CreateObject("AcroExch.HiliteList")
If PageContent.Add(0, 9000) <> True Then
Exit Sub
End If
Set AcroTextSelect = PageNumber.CreatePageHilite(PageContent)
For j = 0 To AcroTextSelect.GetNumText - 1
Content = Content & AcroTextSelect.GetText(j)
Next j
Next i
AcroAVDoc.Close True
AcroApp.Exit
Set AcroDoc = Nothing
Set AcroApp = Nothing
End Sub