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
LVL 4
RichWAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RichWAuthor Commented:
AndyAelbrecht,

Thank you.  That worked perfectly!

Thanks again.

RichW
0
AndyAelbrechtCommented:
cheers dude, you're welcome ! :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.