Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 816
  • Last Modified:

Add a PageBreak into Excel

Hi All,

This should be an easy one.  I am trying to add a Pagebreak into an Excel sheet, and for the life of me I can't figure out how to do it.  I am able to create the sheet and add all of my data, but I cannot get the pagebreak to work.

Can someone show me how to add a pagebreak?

VB.Net 2003
Excel 2002

Thanks

RichW
0
RichW
Asked:
RichW
  • 2
1 Solution
 
AndyAelbrechtCommented:
hey,

in excel vba (99% similar in vb.net):

'this is horizontal so only the number matters (A20 = row 20)
ThisWorkbook.Worksheets.HPageBreaks.Add Range("A20")

'this is vertical so only the letter matters (D1 = column D)
ThisWorkbook.Worksheets.VPageBreaks.Add Range("D1")

this adds the pagebreaks to ALL the worksheets in the open workbook.
use ThisWorkbook.Worksheets(x) to do it on 1 sheet only.

warning though: Excel 2002 could *hang* when using the hpagebreaks.add or/and vpagebreaks.add function. this might or might not be fixed in the current service pack (don't know as i switched to office 2003 before this was fixed).

i hope this helps !
cheers,

Andy
0
 
RichWAuthor Commented:
AndyAelbrecht,

Thank you.  That worked perfectly!

Thanks again.

RichW
0
 
AndyAelbrechtCommented:
cheers dude, you're welcome ! :-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now