[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1165
  • Last Modified:

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"
'********************************************************************************************************
        'CONVERT DOCS TO PDF
'********************************************************************************************************
        '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
 
'*********************************************************************************
           'THIS IS WHERE CODE FAILS
            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

0
chtullu135
Asked:
chtullu135
  • 2
1 Solution
 
rockiroadsCommented:
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
0
 
chtullu135Author Commented:
I think it was a compatibility issue.  In Acrobat I ran the Repair utility and everything then worked.  Go figure.
0
 
rockiroadsCommented:
Cool :)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now