title: PDF-XChange Editor SDK to merge multiple PDF with VBA (Excel)
body: <p>Im trying to merge multiple PDF files into a single one... and thanks to a snippet i found on the support forums from the PDF-XChange, i was able to do it. Problem is it only allows me to do it once. After that it generates an error, like if something was left open.</p>
  <p><strong>If i close the excel file</strong> (its where im developing the code), <strong>i can execute the routine again (once)</strong>.</p>
  <p>The error i get is:</p>
  <p><a href="https://i.stack.imgur.com/1k252.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1k252.png" alt="enter image description here" /></a></p>
  <p>The error is generated in the method <code>Doc.WriteToFile</code></p>
  <p>For the sake of testing, i created a simple routine:</p>
  <pre><code>Public Sub CreateDoc()
      Dim PXC As New PXC_Inst
      Dim Doc As IPXC_Document
      
      'Initialize
      PXC.Init &quot;&quot;
      
      'Create new document, save as pdf
      Set Doc = PXC.NewDocument()
      Doc.WriteToFile &quot;c:\users\syntax\desktop\Test.pdf&quot;
      
      'Close document and Finalize
      Doc.Close
      PXC.Finalize
  End Sub
  </code></pre>
  <p>Below its the required reference (after installing the PDF-XChange Core API SDK):</p>
  <p><a href="https://i.stack.imgur.com/HZt9L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HZt9L.png" alt="enter image description here" /></a></p>
  <p><strong>Could anyone kindly give me a hint</strong> on this matter?
  Many thanks!</p>