DDE : DocInsertPages

Another PDF document is inserted after the page for which the PDF document is specified.
It doesn’t operate in Acrobat Reader.


[DocInsertPages(char* fullPath, long insertAfterPage, char* sourcePath)]



The full path of updated PDF document.
It is page number of insertion (insertion) beginning PDF file specified by the first argument. Page 1 is assumed to be 0. It begins from 0.
It is a full path name of the insertion origin. This PDF file need not been opened.


true The pages are inserted successfully.
false Otherwise.

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


Sample: VBA of Excel

“E:\Test02.pdf” PDF document is added after page 24 of PDF document (Test01.pdf).

  • Please confirm the test by the step execution with F8 key.

Sub DDE_DocInsertPages()
Β Β Β  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 Acrobatapplication is Started.
Β Β Β  ‘Shell “C:\Program Files\Adobe\Acrobat 7.0Β Β Β  \Acrobat\Acrobat.exe”
Shell “C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Acrobat.exe”

‘Open of DDE channel
lChanNo = DDEInitiate(“Acroview”, “Control”)

‘Open of PDF file
DDEExecute lChanNo, “[DocOpen(” & CON_PDF_PATH & “)]”
‘E:\Test02.pdf” PDF document is added after page 24 of PDF document (Test01.pdf).
DDEExecute lChanNo, “[DocInsertPages(” & _
CON_PDF_PATH & “,23,E:\Test02.pdf)]”
‘Saving of PDF file. Note) Optimization is not done.
DDEExecute lChanNo, “[DocSave(” & CON_PDF_PATH & “)]”

‘The Acrobat applicaton is ended..
‘If this is not done, the Acrobat process remains.

DDEExecute lChanNo, “[AppHide()]”
‘The DDE channel is shut.
DDETerminate lChanNo
End Sub


  • If page number that doesn’t exist in the second argument is specified, it becomes False.
  • All pages of the PDF document specified by the third argument are inserted.
  • False is returned by the return value when demanding of deleting all pages. And, the method is disregarded.
  • It doesn’t operate in Acrobat Reader.

Environment to confirm the operation

  • WindowsXP + SP3 + WindowsUpdate
  • Adobe Acrobat Pro 7.0.8 + Office 2003 Pro
  • Adobe Acrobat Pro 8.1.4 + Office 2003 Pro