Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Method 'Add' of object 'HPageBreaks' failed

Status
Not open for further replies.

OzzieOwl

Technical User
Dec 13, 2001
45
0
0
GB
Not sure if anyone can help, but I am getting the following error message when running some VBA code in Excel 2000

Run-time error '-2147417848(80010108)
Method 'Add' of object 'HPageBreaks' failed

Then when I choose End or Debug I get the following Error Message

The instruction at "0x77fc8dbd" referenced memory at "0x00000000". The memory could not be "Written".

Then when I click on OK or Cancel, Excel terminates.

If I remove the Page Break line form the VBA the Macro works correctly.

The Code I am using is

Rows(ReportLoop + 2 & ":" & ReportLoop + 2).Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell

Any help would be appreciated

Cheers

Ozzie

 
Hi,

Is your procedure in a module and NOT in a sheet object?

BTW, This will work better without selecting...
Code:
   ActiveWindow.SelectedSheets.HPageBreaks.Add _
Before:=Rows(ReportLoop + 2 & ":" & ReportLoop + 2)
faq707-4105 How Can I Make My Code Run Faster?

:)

Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top