Unable to create PDF with MSWord 2010 in Windows 8

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
DamianPM
Posts: 13
Joined: Thu May 07 2009

Unable to create PDF with MSWord 2010 in Windows 8

Post by DamianPM »

I have following VBA in Microsoft Word 2010 and OS is Windows 8(CDINTF 2.5.1.4)
When it prints I get "65535 Error opening PDF Document" error always.
But there is no problem in Windows 7.
What may be the reason for this?

Code: Select all

Option Explicit

Public Sub PDFPrint()

    Dim strActivePrinterMemory  As String
    Dim cdiPDFPrinter           As Object
    Dim docPDF                  As Object
    
    Const PDF_DRIVER_NAME = "MYPDFPrinter"
    Const PDF_FILE_PRINT_OPTION_RESET = 0
    Const PDF_FILE_PRINT_OPTION_NO_PROMPT = 1
    Const PDF_FILE_PRINT_OPTION_USE_FILE_NAME = 2
    Const PDF_FILE_PRINT_OPTION_CONCATENATE = 4
    Const PDF_FILE_PRINT_OPTION_DISABLE_COMPRESSION = 8
    Const PDF_FILE_PRINT_OPTION_EMBED_FONTS = 16
    Const PDF_FILE_PRINT_OPTION_BROADCAST_MESSAGES = 32
    Const PDF_PAPER_SIZE_A4 = 9
    Const PDF_PAPER_ORIENTATION_PORTRAIT = 1
    Const PDF_PERM_OWNER_PASSWORD = "Test"
    Const PDF_PERM_USER_ALLOW_PRINTING = &H4
    Const PDF_PERM_USER_ALLOW_CHANGING_DOC = 8
    Const PDF_PERM_USER_ALLOW_COPYING = 16
    Const PDF_PERM_USER_ALLOW_NOTES = &H32
    Const PDF_COMP_256_COLOUR = &H800000
    
    Const pdf_AmyuniLicenseCompany = "???"
    Const pdf_AmyuniLicenseCode = "???"

    On Error GoTo Err_PDFPrint
    
    'Initialise PDF printer
    Set cdiPDFPrinter = CreateObject("CDIntfEx.CDIntfEx")
    With cdiPDFPrinter
        .DriverInit PDF_DRIVER_NAME
        'Set margins to zero
        .HorizontalMargin = 0
        .VerticalMargin = 0
        .SetDefaultConfig
   'Set paper size & orientation
        .PaperSize = PDF_PAPER_SIZE_A4
        .Orientation = PDF_PAPER_ORIENTATION_PORTRAIT
    End With
    'Set PDF printer
    strActivePrinterMemory = Application.ActivePrinter
    If Not CBool(InStr(1, Application.ActivePrinter, PDF_DRIVER_NAME, vbTextCompare)) Then Application.ActivePrinter = PDF_DRIVER_NAME
    'Print doc to PDF
    With cdiPDFPrinter
        .EnablePrinter pdf_AmyuniLicenseCompany, pdf_AmyuniLicenseCode
        'Set PDF page file name
        .DefaultFileName = "C:\" & Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4) & ".pdf"
        'Set options
        .FileNameOptionsEx = PDF_FILE_PRINT_OPTION_NO_PROMPT + PDF_FILE_PRINT_OPTION_USE_FILE_NAME + PDF_COMP_256_COLOUR
        'Print doc to PDF file
        ActiveDocument.PrintOut Background:=False
        'Reset FileNameOptions
        .FileNameOptionsEx = PDF_FILE_PRINT_OPTION_RESET
    End With

    Set cdiPDFPrinter = Nothing
    'Reset default printer
    If Application.ActivePrinter <> strActivePrinterMemory Then Application.ActivePrinter = strActivePrinterMemory
    'Create PDF document object
    Set docPDF = CreateObject("CDIntfEx.Document")
    'Activate advanced functions
    docPDF.SetLicenseKey pdf_AmyuniLicenseCompany, pdf_AmyuniLicenseCode
    'Open created document
    docPDF.Open ("C:\" & Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4) & ".pdf")
    'Set permissions
    docPDF.Encrypt PDF_PERM_OWNER_PASSWORD, "", &HFFFFFFC0 + PDF_PERM_USER_ALLOW_COPYING + PDF_PERM_USER_ALLOW_PRINTING
    'Set properties
    docPDF.Subject = Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4)
    'Save finished document
    docPDF.Save ("C:\" & Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4) & ".pdf")
    Set docPDF = Nothing

Exit_PDFPrint:
    On Error GoTo 0
    Exit Sub

Err_PDFPrint:

    Set docPDF = Nothing
    Set cdiPDFPrinter = Nothing
    
    Select Case Err.Number
        Case Else:
            MsgBox Err.Number & "-" & Err.Description, vbCritical + vbOKOnly, "Error message"
    End Select
    
    Resume Exit_PDFPrint

End Sub
Rich
Posts: 76
Joined: Thu Jun 16 2011

Re: Unable to create PDF with MSWord 2010 in Windows 8

Post by Rich »

Version 4.5.2.7 is available to demo and more information can be found here: http://amyuni.com/en/developer/pdfconverter

Amyuni PDF Converter 4.5 is the result of more than a year of continual improvements over the previous 4.0 release. With Windows 7 and 64-bit OS becoming the standards in the PC market, all the aspects of running under these environments have been reviewed and optimized.

We have ran internal testing for Windows 8 (Release Preview) to get Microsoft certification using the Windows Hardware Certification Kit and the tests went well.
http://msdn.microsoft.com/library/windo ... e/br259114
Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - http://www.amyuni.com
DamianPM
Posts: 13
Joined: Thu May 07 2009

Re: Unable to create PDF with MSWord 2010 in Windows 8

Post by DamianPM »

Code: Select all

Sub PDFPrint()

    Dim strActivePrinterMemory  As String
    Dim cdiPDFPrinter           As Object
    Dim docPDF                  As Object
    
    Const PDF_DRIVER_NAME = "QASPDFPrinter"
    Const PDF_FILE_PRINT_OPTION_RESET = 0
    Const PDF_FILE_PRINT_OPTION_NO_PROMPT = 1
    Const PDF_FILE_PRINT_OPTION_USE_FILE_NAME = 2
    Const PDF_FILE_PRINT_OPTION_CONCATENATE = 4
    Const PDF_FILE_PRINT_OPTION_DISABLE_COMPRESSION = 8
    Const PDF_FILE_PRINT_OPTION_EMBED_FONTS = 16
    Const PDF_FILE_PRINT_OPTION_BROADCAST_MESSAGES = 32
    Const PDF_PAPER_SIZE_A4 = 9
    Const PDF_PAPER_ORIENTATION_PORTRAIT = 1
    Const PDF_PERM_OWNER_PASSWORD = "Test"
    Const PDF_PERM_USER_ALLOW_PRINTING = &H4
    Const PDF_PERM_USER_ALLOW_CHANGING_DOC = 8
    Const PDF_PERM_USER_ALLOW_COPYING = 16
    Const PDF_PERM_USER_ALLOW_NOTES = &H32
    Const PDF_COMP_256_COLOUR = &H800000

    Const pdf_AmyuniLicenseCompany = "Amyuni Technologies Eval Version"
    Const pdf_AmyuniLicenseCode = "07EFCDAB0100010031825101B257659266255C64F543DF28853EEACF7AFD9DC81D66B62926B87CEC1161728458C731CE6C2429A6B440"
    
    On Error GoTo Err_PDFPrint
    
    'Initialise PDF printer
    Set cdiPDFPrinter = CreateObject("CDIntfEx.CDIntfEx.4.5")
    
    With cdiPDFPrinter
        .DriverInit PDF_DRIVER_NAME
        
        'Set margins to zero
        .HorizontalMargin = 0
        .VerticalMargin = 0
        .SetDefaultConfig
        
        'Set paper size & orientation
        .PaperSize = PDF_PAPER_SIZE_A4
        .Orientation = PDF_PAPER_ORIENTATION_PORTRAIT
    End With
    
    'Set PDF printer
    strActivePrinterMemory = Application.ActivePrinter
    If Not CBool(InStr(1, Application.ActivePrinter, PDF_DRIVER_NAME, vbTextCompare)) Then
        Application.ActivePrinter = PDF_DRIVER_NAME
    End If
    
    'Print doc to PDF
    With cdiPDFPrinter
        .EnablePrinter pdf_AmyuniLicenseCompany, pdf_AmyuniLicenseCode
        'Set PDF page file name
        .DefaultFileName = "C:\\TestPDF\\TestPDF.PDF"
        
        'Set options
        .FileNameOptionsEx = PDF_FILE_PRINT_OPTION_NO_PROMPT + PDF_FILE_PRINT_OPTION_USE_FILE_NAME + PDF_FILE_PRINT_OPTION_DISABLE_COMPRESSION
        .FileNameOptions = PDF_FILE_PRINT_OPTION_NO_PROMPT + PDF_FILE_PRINT_OPTION_USE_FILE_NAME + PDF_FILE_PRINT_OPTION_DISABLE_COMPRESSION
        
        .EnablePrinter pdf_AmyuniLicenseCompany, pdf_AmyuniLicenseCode
        'Print doc to PDF file
        ActiveDocument.PrintOut
        
        'Reset FileNameOptions
        .FileNameOptionsEx = PDF_FILE_PRINT_OPTION_RESET
    End With

Exit_PDFPrint:
    On Error GoTo 0
    Exit Sub

Err_PDFPrint:

    Set docPDF = Nothing
    Set cdiPDFPrinter = Nothing
    
    Select Case Err.Number
        Case Else:
            MsgBox Err.Number & "-" & Err.Description, vbCritical + vbOKOnly, "Error message"
    End Select
    
    Resume Exit_PDFPrint
End Sub
I installed Amyuni PDF Converter 4.5 and tried above coding.
It creates C:\\TestPDF\\TestPDF.PDF file but size is 0bytes.
Since my old Amyuni 2.5 works in Windows 7 with Office 2010 but latest Amyuni doesn’t work in Windows 8 with Office 2010.
Is there anything to change in Windows 8?
Rich
Posts: 76
Joined: Thu Jun 16 2011

Re: Unable to create PDF with MSWord 2010 in Windows 8

Post by Rich »

Two things to check:

1. ensure on a 64-bit PC that the PDF printer is assigned to the NUL: port
2. change to "Print directly to the printer" under Printer properties | Advanced tab.

You may consider taking off "Broadcast messages".

Hope this helps.
Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - http://www.amyuni.com
DamianPM
Posts: 13
Joined: Thu May 07 2009

Re: Unable to create PDF with MSWord 2010 in Windows 8

Post by DamianPM »

Windows 8 is 32bit. I tried with NUL: port also but no luck.
Print directly to the printer option is selected. But still the problem exist.
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Re: Unable to create PDF with MSWord 2010 in Windows 8

Post by Jose »

Hello,

On another note, using the Amyuni PDF Converter developer edition to create a MsWord macro is not supported in the standard developer\application license.
http://www.amyuni.com/en/developer/devlicense/

Thanks
Get PDF Suite, the expert .NET developer toolkit for PDF conversion, creation and editing - www.amyuni.com/pdfsuite
Post Reply