Intermittent Error - Method 'Add' of object 'HPageBreaks' failed
That got it... thanks so much. I did suspect that the ActiveCell
reference was the culprit, but couldn't find any other code that used a
different opject there and wasn't sure how to fix it.
Thanks again!
~Jamey
NickHK wrote:
You are writing this code in Access ?
If so, you can't use ActiveCell (an other unqualified Excel objects) and
.Selects are a bad idea.
So use
With xlWs
BotRow = .Cells.SpecialCells(xlCellTypeLastCell).Row
Set xlRng = .Cells(BotRow + 3, 1)
If BotRow 13 Then
.HPageBreaks.Add Befo=xlRng
End If
End With
NickHK
"Jamey Weare" wrote in message
oups.com...
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
|