View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jamey Weare Jamey Weare is offline
external usenet poster
 
Posts: 8
Default Intermittent Error - Method 'Add' of object 'HPageBreaks' failed

I get a compile error that selects the Add method, stating that an
argument is not optional. I have Access 2002 which I guess has a
different version of that method than you.
Anyone have any other ideas?

The code I have at the moment is:

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

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

If BotRow 13 Then
xlWs.HPageBreaks.Add Befo=ActiveCell
End If


I have tried quite a few different ways of doing this, bt it 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.




Jamey Weare wrote:
I'll give that a shot... thanks.


NickHK wrote:
Jamey,
This works for me:
With xlWs
.HPageBreaks.Add .Range("A13")
End With

No need to .Select

NickHK