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: 8
Default Intermittent Error - Method 'Add' of object 'HPageBreaks' failed

I am having trouble with an automation project that I am working on. I
am generating a report in a spreadsheet. Originally I attempted to do
it in Access, but it did not provide me enough flexibility to
accomplish what I was looking to do. The report is an old report that
was manually created in Excel and they wanted to format to remain the
same, but automate it. Everything has been going great up until this
one bit of code...

Essentially the report is in a format something like this:
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\
Type 1
| header 1 | header 2 | header 3 |
| details | details | details |
----------------------------------------------
subtotals

Type 2
| header 1 | header 2 | header 3 |
| details | details | details |
----------------------------------------------
subtotals

| header 1 | header 2 | header 3 |
grand totals

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\
For most of my organizational units this all fits on one page, but for
a few it does not. When it does not I want to drop the Type 2 section
to its own page. The code below is what I am using to accomplish this
and it is working most of the time. I am randomly getting the error
that is listed in the subject line of this message.

If BotRow 13 Then
BotRow = BotRow + 3
Set xlRng = xlWs.Range("A" & BotRow)
xlRng.Select
xlWs.HPageBreaks.Add Befo=ActiveCell <<<< Error on this
line
End If

Any ideas as to what could be causing this error? It does not seem to
matter if Excel is already open or if all instances are closed.

Is there another way to insert a page break at a given point?

I am using Access 2002 SP-1 and Excel 2003 SP-3 on a WinXP machine. If
you need more info to come up with an answer just let me know.


Jamey Weare
Business Analyst
Florida Power & Light

 
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
Charts.Add error '1004' Method 'Add' of object 'Sheets' failed Corey Charts and Charting in Excel 1 December 28th 06 02:15 PM
Intermittent Error - Method 'Add' of object 'HPageBreaks' failed Jamey Weare Excel Worksheet Functions 1 December 22nd 06 01:40 AM
Method 'Union' of object '_Global' failed error sloth Excel Programming 1 October 2nd 06 07:09 AM
HELP - 'Add' of object 'CommandBarControls' failed LAF Excel Discussion (Misc queries) 1 September 20th 05 01:53 AM
Method 'Add' of object 'CommandBarControls' failed LAF Excel Discussion (Misc queries) 0 September 12th 05 02:02 PM


All times are GMT +1. The time now is 09:50 PM.

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"