Tutorial :Page Breaks In Excel VB.Net


I'm working with the Office Interop and having trouble inserting page breaks in Excel. My code is working fine with the horizontal page break but I also need to set the vertical pagebreak. Can somone modify my code below, to make a vertical page break on column I?

This code is making the correct horizontal pagebreaks but is still 150 pages long because the vertical pagebreak is not set correctly.

Dim r As Excel.Range = CType(xlWorkSheet.Cells(27, 1), Excel.Range)    r.PageBreak = 1  


Try setting the vertical pagebreak for the right Column object itself, rather than the cells range.




worked for me to set a vertical page break. As shown in the picture, it seems to put the page break before the specified column: enter image description here


If you want page like A1:D15
for that

excelWorksheet.Range(E16).PageBreak = 1   

It will create both vertical and horizontal page break.

This is just example. Code accordingly.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »