DDE : DocPrint

It prints without doing the print range page in PDF file, presenting, and displaying the print dialog box. When printing, the size is changed to install on the printing area and it is printed.
It doesn’t operate in Acrobat Reader.


[DocPrint(char* fullPath, long startPage, long endPage)]


The full path of PDF file
Print beginning page number.
The beginning page : from 0.
Print end page number.
The end page : from 0.


true The print succeeded.
false The document specified by fullPath is not opened.The print failed.

Notes: The return value cannot be acquired with DDE of VBA of Excel.

Sample: VBA of Excel

The PDF document is opened.

  • Please confirm the test by the step execution with F8 key.
  • Following Sleep API is put in a standard module.

Public Declare Sub Sleep Lib “kernel32” _
    (ByVal dwMilliseconds As Long)

Sub DDE_DocPrint()
    Dim lChanNo As Long      ‘DDE channel number
    ‘A double quotation mark is added for blank starting full path.
    Const CON_PDF_PATH = “””E:\Test01.pdf”””
    ‘The Acrobat application is Started.
    Shell “C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Acrobat.exe”
    ‘Open of DDE channel
    lChanNo = DDEInitiate(“Acroview”, “Control”)
    ‘E:\Test01.pdf’ PDF file is displayed.
    DDEExecute lChanNo, “[DocOpen(“ & CON_PDF_PATH & “)]”
    ‘Only page 1 of the cover is printed.
    DDEExecute lChanNo, “[DocPrint(“ & CON_PDF_PATH & “,0,0)]”
    ‘The control returns immediately because DDE of DocPrint processes the asynchronization.
    ‘It cannot be printed that it doesn’t buy time by Sleep.
    Sleep 2000  ‘=Two seconds.It is OK in the test from 300.
    ‘All PDF is shut, and the Acrobat applicaton is ended.
    ‘The Acrobat process also disappears.

    DDEExecute lChanNo, “[AppExit()]” 
    ‘The DDE channel is shut.
    DDETerminate lChanNo
    Debug.Print Now & “ Finish”
End Sub


  • It doesn’t operate in Acrobat Reader.
  • The process doesn’t remain in the above-mentioned sample though the problem that the process remains in the memory is seen well for an automatic print that uses Acrobat Reader. This problem doesn’t occur in Acrobat Reader v9.1.


– Describing concerning this clearly is not found in Acrobat SDK.

  • It is necessary to open the PDF document beforehand. It is necessary to execute FileOpen or DocOpen method beforehand.
  • The DDE control returns immediately without waiting until the printing job is begun. In a word, the following instruction is executed. (AppExit) that shuts the DDE channel afterwards and the print are disregarded. It is necessary to do the temporization until the print of the Sleep function is begun. It is expected that time changes by the personal computer environment etc.

Environment to confirm the operation

  • WindowsXP + SP3 + WindowsUpdate
  • Acrobat Reader 8.1 + Office Pro 2003