DDE : DocInsertPages

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

Syntax

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

Argument

 

fullPath
[char*]
The full path of updated PDF document.
insertAfterPage
[long]
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.
sourcePath
[char*]
It is a full path name of the insertion origin. This PDF file need not been opened.

Returns

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

Remarks

  • 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