Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default insert page breaks

Bruce,
If you want the bottom of the page according to Excel/page set up/printer
margins etc the you want automatic page breaks.
If you are inserting page breaks, then you are deciding where the end of the
page is and you need to decide where "Add Befo=ActiveCell" should be
located.

In relation to pagebreaks there is also the "ExecuteExcel4Macro()" function
(with the correct argument, that I've forgotten at the moment) that return
page break info and seems more reliable than the newer collection.

However, as you page size is already set, do you mean to place/size your
charts correctly instead ?

NickHK

"Bruce" wrote in message
...
I have a worksheet in which I add a number of charts via vba. The number

of
charts added changes (eg may be 6 or 20 or more) depending on my data. The
arragement on the page is 2 x n where there are 2 across the page that fit
the print area.

How do I find the bottom of each page so that I can insert the required

page
breaks into the worksheet with the following or something else;

ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell

Bruce



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default insert page breaks

Hi Nick,

I have setup the printer margins and in terms of width the charts fit.
However vertically the charts overlap pages in their current positioning. I'm
not sure as you say, how to determine where the bottom of the page is so that
those charts can be positioned correctly.

This is the code I am using to add size and position the charts. I guess its
somewhere around the .top but any help is appreciated.

Bruce

Private Sub lineupCharts()
Dim MyWidth As Single, MyHeight As Single
Dim NumWide As Long
Dim iChtIx As Long, iChtCt As Long

arrChart = Array("Chart_Int", "Chart_Short", "Chart_Long")

MyWidth = 240
MyHeight = 145
NumWide = 2
For Each a In arrChart
Sheets(a).Activate
iChtCt = ActiveSheet.ChartObjects.Count
For iChtIx = 1 To iChtCt


With ActiveSheet.ChartObjects(iChtIx)
.Width = MyWidth
.Height = MyHeight
.Left = ((iChtIx - 1) Mod NumWide) * MyWidth
.Top = Int((iChtIx - 1) / NumWide) * MyHeight
End With
Next
Next a

End Sub




"NickHK" wrote:

Bruce,
If you want the bottom of the page according to Excel/page set up/printer
margins etc the you want automatic page breaks.
If you are inserting page breaks, then you are deciding where the end of the
page is and you need to decide where "Add Befo=ActiveCell" should be
located.

In relation to pagebreaks there is also the "ExecuteExcel4Macro()" function
(with the correct argument, that I've forgotten at the moment) that return
page break info and seems more reliable than the newer collection.

However, as you page size is already set, do you mean to place/size your
charts correctly instead ?

NickHK

"Bruce" wrote in message
...
I have a worksheet in which I add a number of charts via vba. The number

of
charts added changes (eg may be 6 or 20 or more) depending on my data. The
arragement on the page is 2 x n where there are 2 across the page that fit
the print area.

How do I find the bottom of each page so that I can insert the required

page
breaks into the worksheet with the following or something else;

ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell

Bruce




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default insert page breaks

Bruce,
"ActiveWindow.SelectedSheets.HPageBreaks(1).Locati on.Address" will give you
address of the first break.
You can also set the Location to a range to insert a break.

Do that help ?

NickHK

"Bruce" wrote in message
...
Hi Nick,

I have setup the printer margins and in terms of width the charts fit.
However vertically the charts overlap pages in their current positioning.

I'm
not sure as you say, how to determine where the bottom of the page is so

that
those charts can be positioned correctly.

This is the code I am using to add size and position the charts. I guess

its
somewhere around the .top but any help is appreciated.

Bruce

Private Sub lineupCharts()
Dim MyWidth As Single, MyHeight As Single
Dim NumWide As Long
Dim iChtIx As Long, iChtCt As Long

arrChart = Array("Chart_Int", "Chart_Short", "Chart_Long")

MyWidth = 240
MyHeight = 145
NumWide = 2
For Each a In arrChart
Sheets(a).Activate
iChtCt = ActiveSheet.ChartObjects.Count
For iChtIx = 1 To iChtCt


With ActiveSheet.ChartObjects(iChtIx)
.Width = MyWidth
.Height = MyHeight
.Left = ((iChtIx - 1) Mod NumWide) * MyWidth
.Top = Int((iChtIx - 1) / NumWide) * MyHeight
End With
Next
Next a

End Sub




"NickHK" wrote:

Bruce,
If you want the bottom of the page according to Excel/page set

up/printer
margins etc the you want automatic page breaks.
If you are inserting page breaks, then you are deciding where the end of

the
page is and you need to decide where "Add Befo=ActiveCell" should be
located.

In relation to pagebreaks there is also the "ExecuteExcel4Macro()"

function
(with the correct argument, that I've forgotten at the moment) that

return
page break info and seems more reliable than the newer collection.

However, as you page size is already set, do you mean to place/size your
charts correctly instead ?

NickHK

"Bruce" wrote in message
...
I have a worksheet in which I add a number of charts via vba. The

number
of
charts added changes (eg may be 6 or 20 or more) depending on my data.

The
arragement on the page is 2 x n where there are 2 across the page that

fit
the print area.

How do I find the bottom of each page so that I can insert the

required
page
breaks into the worksheet with the following or something else;

ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell

Bruce






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I insert data into my spreadsheet without the page breaks. J D Excel Worksheet Functions 1 August 13th 08 07:39 PM
Excel: how to insert page breaks between all the rows at once? Kim Excel Discussion (Misc queries) 1 June 25th 08 09:37 PM
How do I insert page breaks in .txt for use in excel? JohnK Excel Discussion (Misc queries) 2 January 19th 07 11:24 PM
Insert Multiple Page Breaks heater Excel Worksheet Functions 1 September 13th 06 10:35 PM
insert page breaks every 43 lines chase Excel Programming 2 August 6th 03 03:42 PM


All times are GMT +1. The time now is 08:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"