title: Using VBA to Print Data From Excel to PDF
body: <p>Seemingly very simple question but I have an excel spreadsheet that uses vba code to take a screenshot of something, pastes it into a 'Screenshot' tab and then exports that tab to a pdf. My issue is that the page break that I pass does not line up with the dotted page break line that seems to be produced by default(?)...  </p>
  
  <p>Section of Code:</p>
  
  <pre><code>Set Screen = Sheets("Screenshots")
  Set Block = Sheets("BlockChart")
  Set CopyRangeBlock = Block.Range("A1:N51")
  Set PasteRange = Screen.Cells(1, 1)
  Application.DisplayStatusBar = True
  CopyRangeBlock.CopyPicture xlScreen, xlPicture
  DoEvents
  Screen.Paste Destination:=PasteRange
  DoEvents
  Sheets("Screenshots").Rows(52).PageBreak = xlPageBreakManual
  Application.CutCopyMode = False
  </code></pre>
  
  <p>The range of the data to screenshot is from "A1:N:51" and therefore I place a page break at row 52. However, a dotted page break line appears (seemingly by default) at row 50. This screws up my export to pdf and produces blank pages. This is particularly an issue when I loop through the code to generate multiple pages in a pdf. How can I make it so that the dotted line either doesn't appear or matches with the page break that I set so that I'm not getting extra blank pages?</p>
  
  <p>Example:</p>
  
  <p><a href="https://i.stack.imgur.com/tVF3G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tVF3G.png" alt="enter image description here"></a></p>
  
  <p>Just to reiterate the point, the whole worksheet has pre-determined dotted lines for the print area. I essentially want to modify these (via manual breaks or something) so that each page printed to a pdf is a custom size that fits the data I screenshot.</p>
  
  <p><a href="https://i.stack.imgur.com/lv0NT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lv0NT.png" alt="enter image description here"></a></p>