5142 error when attemtpting to print to pdf from word 2007

I am migrating an Access 2003 application to 2007.  The application has an option to allow users to create word, pdf, and text copies to file.  The problem is that the code crashes when attempting to create the pdf file.  The 2003 version works fine.  I've already set the Adobe PDF setting and cleared the box labeled "Rely on system fonts only; do not use document fonts"
        'Open the folder with all the new Access
    Set fso = New FileSystemObject
    Set fldr = fso.GetFolder(stPath)
        'Open a new Distiller object
    Set oDistiller = New PdfDistiller6
        'Enumerate files in the save folder and convert .doc to .pdf
    SysCmd acSysCmdSetStatus, "Converting Word documents to Adobe PDF files...Please Wait..."
    For Each fl In fldr.Files
        If Right(fl.Name, 4) = ".doc" Then
            sOutputPDFName = stPath & Left(fl.Name, Len(fl.Name) - 3) & "pdf"    'Set pdf name
            Set wdDoc = wdObj.Documents.Open(stPath & fl.Name)                   'Open Doc
            wdDoc.PrintOut False, , , stPath & "tmp"                             'Print a temp ps file   
            wdDoc.Close False                                                    'Close the Doc
            oDistiller.FileToPDF stPath & "tmp", sOutputPDFName, "Print"         'Convert temp ps the .pdf
            Kill stPath & "tmp"                                                  'Delete the temp ps file
        End If
    Next fl
    Set oDistiller = Nothing
    Set fso = Nothing

Open in new window

Juan VelasquezAsked:
Who is Participating?
rockiroadsConnect With a Mentor Commented:
Without automation, can you manually print to pdf when you open a word 2007 doc? If you cant there then that could explain it.

Its nothing silly like updated drivers required or anything like that is it? What version acrobat you got. I dont know if there are compatability problems maybe with the version you have with office 2007
Juan VelasquezAuthor Commented:
I think it was a compatibility issue.  In Acrobat I ran the Repair utility and everything then worked.  Go figure.
Cool :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.