title: Insert page breaks in Excel to split data for printing .pdf
body: <p>I am working with an Excel file that can contains dynamic rows. I export it to .pdf and it works well. The matter is that all the content is on a single page in the .pdf file.  </p>
  
  <p>Is there anyway to insert page breaks in my VBA for my .pdf file?</p>
  
  <p><strong>EDIT:</strong> Here is my code for the page break. Won't seems to get working</p>
  
  <pre><code>If count &gt; 30 Then ' count is the number of row. Break at every 15 rows
          Set ws = Range("A1", "K" &amp; count) 'The range of the document
          Dim ii As Integer
          ii = 21 ' first page break
          While count &gt; 0
              If count &gt; 15 Then ' no page break if there is less than 15 rows
               ws.Rows(ii).EntireRow.PageBreak = xlPageBreakManual
              End If               
              ii = ii + 15
              count = count - 15
          Wend
  End If
  </code></pre>
  
  <p><strong>EDIT 2:</strong> I did not find any way to create a page break into the pdf file. However, I still resolve my problem. I just find a module for vba to run external process and wait for them. it is <a href="http://www.cpearson.com/Excel/ShellAndWait.aspx" rel="nofollow noreferrer">ShellAndWait</a></p>
  
  <p>I save every page of my pdf file as a temporary document and send it's path/name to a  C# console application that I've created. I am using the library <a href="https://www.nuget.org/packages/PDFsharp/" rel="nofollow noreferrer">PDFsharp</a> to process the pdf documents and then merge them to 1 file.</p>
  
  <p>Hope it could help someone.</p>