in reply to Re^2: excel page breaks???
in thread Help inserting page break in Microsoft Excel using OLE

Given $sheet is
$workbook->Worksheets("Sheet1")
or
$workbook->ActiveSheet

and given $cell is
$sheet->Range("6:6")
or
$sheet->ActiveCell

I think it's
$sheet->HPageBreaks->Add(...)

For arguments, you could try
Before => $cell

I'm really just guessing. MSDN is unusually horrid on this subject.

Replies are listed 'Best First'.
Re^4: excel page breaks???
by jobs_ron (Acolyte) on Mar 01, 2005 at 18:52 UTC
    Thank you for that advice. My code is now:
    use warnings; use strict; use OLE; use Win32::OLE::Const 'Microsoft Excel'; my $excel = CreateObject OLE 'Excel.Application'; my $workbook = $excel -> Workbooks -> Add; my $sheet = $workbook -> Worksheets("Sheet1"); $sheet -> Activate(); $sheet -> Range("6:6") -> Activate(); $sheet -> HPPageBreaks -> Add(Before => $sheet -> ActiveCell);
    I now receive an error for the last line which reads "Can't call method 'Add' on an undefined value." Did I not read your advice correctly>
      Looks like you have an extra P in HPageBreaks. Try removing that (I'm simply comparing to ikegami's code)
      --------------
      It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs
        Don't I feel like a sap? Thank you. Here is the new code:
        use warnings; use strict; use OLE; use Win32::OLE::Const 'Microsoft Excel'; my $excel = CreateObject OLE 'Excel.Application'; my $workbook = $excel -> Workbooks -> Add; my $sheet = $workbook -> Worksheets("Sheet1"); $sheet -> Activate(); $sheet -> Range("6:6") -> Activate(); $sheet -> HPageBreaks -> Add(Before => $sheet -> ActiveCell);
        Now there is no error message, but still no page break.