LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Strange problem with HPageBreaks

Hi Tom

This is a bug

See the link in this macro
http://www.rondebruin.nl/hpagebreaks.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"TomPl" wrote in message ...
Very strange indeed.
If I scroll down to the bottom of the used range the macro works.
If I select PageBreak View the macro works.
If I open the workbook and leave the selected range at "A1" the macro gives
the "out of range" error. It seems that excel doesn't generate the page
breaks until focus is applied to the area to be printed.

Go figure?

"PO" wrote:

Hi,

I have a worksheet with 15 pages of data. ?ActiveSheet.HPageBreaks.Count
returns 14 in the immediate window.
The following code however produces an "Index out of range" error:

Sub FormatDoc()
Dim intI
Dim pb As HPageBreak
Dim rng As Range

For intI = 1 To ActiveSheet.HPageBreaks.Count
Set rng = ActiveSheet.HPageBreaks(intI).Location
ActiveSheet.Range(rng.Address).Resize(1,
10).Borders(xlEdgeTop).Weight = -4138
Next intI

End Sub

The strange thing is that the error occurs for different intI values (i.e.
intI =2 or intI = 5). And sometimes the whole procedure executes without
errors.
There are no inserted pagebreakes in the worksheet only those set by Excel.

Any ideas?

Regards
Pete



 
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
strange problem -Bryan[_2_] Excel Discussion (Misc queries) 3 May 1st 08 06:56 PM
Strange Problem אלי Excel Programming 2 June 20th 07 09:04 AM
Strange serious problem Norman Jones Excel Programming 0 December 7th 06 01:39 PM
Strange Problem Perry Excel Discussion (Misc queries) 7 April 12th 06 09:52 PM
VBA & API - Strange problem using Philip Excel Programming 0 May 11th 05 09:30 AM


All times are GMT +1. The time now is 03:57 AM.

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

About Us

"It's about Microsoft Excel"