Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8
Default Intermittent Error - Method 'Add' of object 'HPageBreaks' failed

I have tried to accomplish this a number of ways, but the code still
fails intermitently. It always runs fine the first time through.

I get an error that either states that the Add method failed as stated
in the subject or I get a Run-Time error '1004': Application-defined or

object defined error. If I close the database and then run the code
again it works just fine.


BotRow = xlWs.Cells.SpecialCells(xlCellTypeLastCell).Row

Set xlRng = xlWs.Cells(BotRow + 3, 1)
xlRng.Select

If BotRow 13 Then
xlWs.HPageBreaks.Add Befo=ActiveCell <---- Error occurs on
this line.
End If

Someone told me in another board that I could skip making the selection
and then do

xlws.HPageBreaks.Add.Range ("A13")

With that I get a compile error. They must be using a different version
of Excel. This code is being run from an Access automation application
where I am filling in the cells from data that was shaped in access
queries. I have Access 2002 SP1 and Excel 2003 SP2.

I am at my wits end with this error so any help would be appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,290
Default Intermittent Error - Method 'Add' of object 'HPageBreaks' failed

Access is not going to know what "ActiveCell" means.
Also, there should be a space between Add and the Range, so try ...
xlWs.HPageBreaks.Add xlWs.Range("A13")
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Jamey Weare"

wrote in message
I have tried to accomplish this a number of ways, but the code still
fails intermitently. It always runs fine the first time through.
I get an error that either states that the Add method failed as stated
in the subject or I get a Run-Time error '1004': Application-defined or
object defined error. If I close the database and then run the code
again it works just fine.

BotRow = xlWs.Cells.SpecialCells(xlCellTypeLastCell).Row

Set xlRng = xlWs.Cells(BotRow + 3, 1)
xlRng.Select

If BotRow 13 Then
xlWs.HPageBreaks.Add Befo=ActiveCell <---- Error occurs on
this line.
End If

Someone told me in another board that I could skip making the selection
and then do

xlws.HPageBreaks.Add.Range ("A13")

With that I get a compile error. They must be using a different version
of Excel. This code is being run from an Access automation application
where I am filling in the cells from data that was shaped in access
queries. I have Access 2002 SP1 and Excel 2003 SP2.
I am at my wits end with this error so any help would be appreciated.

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
Method 'MailEnvelope' of object '_Worksheet' failed [email protected] Excel Discussion (Misc queries) 1 December 7th 05 11:20 PM
runtime error 1004 method range of object '_global failed valdesd Excel Discussion (Misc queries) 2 October 6th 05 07:26 PM
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
Method 'Paste' of object '_Worksheet' failed markline Excel Discussion (Misc queries) 7 May 28th 05 05:02 AM


All times are GMT +1. The time now is 08:56 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"