5142 error when attemtpting to print to pdf from word 2007

Posted on 2008-11-12
Last Modified: 2012-05-05
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

Question by:chtullu135
    LVL 65

    Accepted Solution

    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

    Author Closing Comment

    I think it was a compatibility issue.  In Acrobat I ran the Repair utility and everything then worked.  Go figure.
    LVL 65

    Expert Comment

    Cool :)

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
    Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
    Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now