Nedd Help With Acrobat Object

doofusboy

Well-known Member
Joined
Oct 14, 2003
Messages
1,325
Have been tasked with fixing something a previous coder supposedly had working that is now no longer working for some reason. We're using Excel2002 and I have no familiarity with Adobe. The following code is failing on the line in bold with error msg that says "Active X component can't create object (429)".

There was no reference to Adobe in the workbook, but even when I added a reference to 'Adobe Acrobat 8.0 Type Library' the error persists. From what I gather, after the PDF is attached to the workbook [elsewhere in the code and working] a new worksheet is to be created and graphics from the PDF are to be copied and pasted into the new worksheet [the copy/paste is what is not working].

Any help or link to help is appreciated.

Rich (BB code):
Public Function iAddPDFWS(FileName As String, WSNumber As Integer, AttchID As String) As Integer
    On Error GoTo ErrHandler
    iAddPDFWS = 0
Dim AcApp As Object ' Acrobat.CAcroApp
Dim AcADoc As Object ' Acrobat.CAcroAVDoc
Dim AcPView As Object ' Acrobat.CAcroAVPageView
Dim AcPDoc As Object ' Acrobat.CAcroPDDoc
Dim lRslt As Long, WkSh As Worksheet, LastWkSh As String
 
    ActiveWorkbook.Unprotect
    Application.EnableCancelKey = xlDisabled
    Set AcApp = CreateObject("AcroExch.App", "")   <----- this line highlighted by error
    Set AcADoc = CreateObject("AcroExch.AVDoc", "")
    lRslt = AcADoc.Open(FileName, "")
    Set AcPView = AcADoc.GetAVPageView
    Set AcPDoc = AcADoc.GetPDDoc
    For lRslt = 1 To AcPDoc.GetNumPages
        Set WkSh = AddTheWkSh(FileName, WSNumber, AttchID, CInt(lRslt), LastWkSh)
        AcPView.ScrollTo 1, 1
        AcPView.GoTo lRslt - 1
        AcApp.SetActiveTool "SelectGraphics", -1
        AcApp.MenuItemExecute "Edit"
        AcApp.MenuItemExecute "SelectAll"
        AcApp.MenuItemExecute "Edit"
        AcApp.MenuItemExecute "Copy"
        WkSh.Paste WkSh.Range(cnPASTE_HERE), False
        WkSh.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
        Set WkSh = Nothing
    Next lRslt
    iAddPDFWS = AcPDoc.GetNumPages
    AcApp.Hide
    AcApp.CloseAllDocs
    AcApp.Exit
    Worksheets(LastWkSh).Activate    '"System Suitability - " & WSNumber & " (page 1)").Activate
    Set AcPView = Nothing
    Set AcPDoc = Nothing
    Set AcADoc = Nothing
    Set AcApp = Nothing
ErrHandler:
    If Err.Number <> 0 Then
        modGeneral.StdError Err, "modAddPDFWS.iAddPDFWS"
    End If
    ActiveWorkbook.Protect Structure:=True
    Application.EnableCancelKey = xlInterrupt
End Function
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Shot in the dark here, but I'm going to assume you don't have a full version of Adobe Acrobat loaded on your machine. And I'm not talking about the free reader, I'm talking about the full version that allows you to create PDF files.
 
Upvote 0
Probably. As an FYI, I do have the full version and am trying to parse out a PDF file myself...not easy and not having much luck. PDFs just aren't easy to work with using VBA. Might have to break down and purchase one of the tools on line.

For grins, try to find and set a reference to any and all Adobe Acrobat references.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top