Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Inserting pagebreak in excel

by davidrw (Prior)
on Nov 09, 2005 at 23:54 UTC ( [id://507254]=note: print w/replies, xml ) Need Help??


in reply to Inserting pagebreak in excel

Recording a macro for it yields this VB code:
Rows("6:6").Select ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
wait .. your code actually worked for me (code borrowed mostly from Using Win32::OLE and Excel - Tips and Tricks).
use strict; use warnings; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); $Win32::OLE::Warn = 3; # Die on Errors. my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); $Excel->{Visible} = 1; my $Book = $Excel->Workbooks->Add(); my $row = 6; $Excel->Worksheets(1)->HPageBreaks->Add({ Before => $Excel->Worksheets +(1)->Range("A$row") });
Update: If i add a $Book->SaveAs('C:\Documents and Settings\David\temp\test.xls'); line in there, then open text.xls, then the page break is NOT there. Hmm.. just crappy Excel behavior??

Update: Yup. !1 is right -- is really is there if you look hard enough ;) OP's and mine code should both work just fine ...

Replies are listed 'Best First'.
Re^2: Inserting pagebreak in excel
by !1 (Hermit) on Nov 10, 2005 at 00:37 UTC

    It's there, just go to View > Page Break Preview then switch back to normal.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://507254]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-03-28 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found