Hi Again Everyone,

It seems I only ever ask for help, not give it! Maybe when "I'm a big boy programmer" I'll be able to do a payback!

Anyway, am having a perplexing problem with trying to merge multiple pdf's into a single pdf using the Acrobat.tlb library.

I have it referenced (Acrobat 8.0) and I am using XP SP2.

My problem is the line...Set oMainDoc = CreateObject("AcroExch.PDDoc")
I tried the command immediately below (now commented out) and the same error occured...Error 430...Class does not support automation etc

I have tried all sorts of variations on the theme to get it to work to no avail
Can someone please tell me whats wrong here?
In every code search I have done, the code used is exactly as I have it and works for them!

Your help is much appreciated in advance.

Code:
Public Function MergePDFFiles(psRawPDFFilesDir As String, _
psSinglePDFOutputDir As String, _
psSinglePDFOutputName As String) As Long

'On Error GoTo MyError
On Error GoTo 0
Dim lErrNum As Long
Dim sErrDesc As String
Dim sMess As String
Dim bFirstDoc As Boolean
Dim sRawPDFFilesDir As String
Dim sSinglePDFOutputDir As String
Dim sSinglePDFOutputName As String
'acrobat library
Dim oMainDoc As Acrobat.AcroPDDoc
Dim otempdoc As Acrobat.AcroPDDoc
'Need to use Adobe internal Java Object
'in order to Add Book marks
Dim oJSO As Object 'JavaScript Object
Dim oBookMarkRoot As Object
Dim oFolder As Scripting.Folder
Dim saryFileSort() As String
Dim oFile As Scripting.File
Dim oFSO As Scripting.FileSystemObject
Dim sBMName As String
Dim lPos As Long
Dim lFile As Long
Dim lBMPageNo As Long

sRawPDFFilesDir = psRawPDFFilesDir
sSinglePDFOutputDir = psSinglePDFOutputDir
sSinglePDFOutputName = psSinglePDFOutputName
Set oFSO = New Scripting.FileSystemObject
Set oFolder = oFSO.GetFolder(sRawPDFFilesDir)
Set oMainDoc = CreateObject("AcroExch.PDDoc")
'Set oMainDoc = New Acrobat.AcroPDDoc

bFirstDoc = True

If oFolder.Files.Count = 0 Then
    Exit Function 'nothing to do
End If

'Because the FSO folder files collection does not allow for
'native sorting, we need to plug all the files into an array to sort
ReDim saryFileSort(1 To oFolder.Files.Count)
lFile = 0
For Each oFile In oFolder.Files
    lFile = lFile + 1
    saryFileSort(lFile) = oFile.Name
Next
'do your sort here, or not
'goUtil.utBubbleSort saryFileSort

For lFile = 1 To UBound(saryFileSort, 1)
    If LCase(Right(saryFileSort(lFile), 4)) = ".pdf" Then
        If bFirstDoc Then 'open the pdf and insert/bookmark first page
            bFirstDoc = False
            Dim IsOpen As Boolean
            IsOpen = oMainDoc.Open(sRawPDFFilesDir & "\" & saryFileSort(lFile))
            Set oJSO = oMainDoc.GetJSObject
            Set oBookMarkRoot = oJSO.bookmarkroot
            sBMName = saryFileSort(lFile)
            lPos = InStr(1, sBMName, "_{", vbBinaryCompare)
            If lPos > 0 Then
                sBMName = Left(sBMName, lPos - 1) & ".pdf"
            End If
            oBookMarkRoot.CreateChild sBMName, "this.pageNum =0", lFile - 1
        Else 'insert/bookmark rest of pages
            Set otempdoc = CreateObject("AcroExch.PDDoc")
            otempdoc.Open sRawPDFFilesDir & "\" & saryFileSort(lFile)
            'get the Book mark page number before the actual insert of new pages            lBMPageNo = oMainDoc.GetNumPages
            oMainDoc.InsertPages oMainDoc.GetNumPages - 1, otempdoc, 0, otempdoc.GetNumPages, 1
            otempdoc.Close
            sBMName = saryFileSort(lFile)
            lPos = InStr(1, sBMName, "_{", vbBinaryCompare)
            If lPos > 0 Then
                sBMName = Left(sBMName, lPos - 1) & ".pdf"
            End If
            oBookMarkRoot.CreateChild sBMName, "this.pageNum =" & lBMPageNo, lFile - 1
        End If
    End If
Next
oMainDoc.Save 1, sSinglePDFOutputDir & "\" & sSinglePDFOutputName
oMainDoc.Close
MergePDFFiles = 33 'saved OK so no error

CLEAN_UP:
        Set oFolder = Nothing
        Set oFile = Nothing
        Set oFSO = Nothing
        Set oBookMarkRoot = Nothing
        Set oJSO = Nothing
        Set oMainDoc = Nothing
        Set otempdoc = Nothing
        Exit Function
MyError:
        'lErrNum = Err.Number
        'sErrDesc = Err.Description
        'MsgBox sErrDesc
        MergePDFFiles = Err.Number
        'Enter you error handler
        Set oFolder = Nothing
        Set oFile = Nothing
        Set oFSO = Nothing
        Set oBookMarkRoot = Nothing
        Set oJSO = Nothing
        Set oMainDoc = Nothing
        Set otempdoc = Nothing
    End Function