Please don't shout when posting, ie avoid writing all in caps.
Take a look at the Worksheet.VPageBreaks collection and the VPageBreak.Type property (xlPageBreakAutomatic).
Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
Unless you set a page break manually to the same or a smaller size that the ones Excel chooses, Excel creates its own page breaks based on the paper and margin dimensions defined for the page and the number of rows & columns that will fit within those dimensions.
hi i am getting the error when i add pagebreak and run excel from vb the first time it runs ok this error appears only next time even though i am properly closing excel
err number:=-2147417851
err description:=Method 'Add' of object 'HPageBreaks' failed
You can't use SelectedSheets for this as it doesn't return a specific sheet and there can only be 1 active cell at any 1 time. Therefore, you must loop eg
Code:
for each sht in selectedsheets
sht.hpagebreaks.add before:=activecell
next
Rgds, Geoff
"Having been erased. the document thjat you are seeking. Must now be retyped"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.