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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel vs inserting a pagebreak...

Status
Not open for further replies.

rcloutie

Programmer
May 26, 2005
164
CA
Hi there,

Maybe not the right forum but...

I'm creating an Excel file from Delphi using late binding.
I'm simply trying to insert a page break after each block of data.

Here's the code I've tried so far:
----------------------------------------------
sRange := 'A66';
Sheets.HPageBreaks.Add(Sheet.Range[sRange]);
----------------------------------------------
iRow := 66;
Sheet.HPageBreaks.Add(Sheet.Cells.Item[iRow,1]);
----------------------------------------------
sRange := 'A66';
Sheet.Range[sRange].PageBreak := xlPageBreakManual;
----------------------------------------------

None of these method works...

Thanks for help,

Rej Cloutier


 
Code:
Sheets := XLApp.Sheets; 
Sheet  := XLApp.Workbooks[1].WorkSheets[Title]; 
Sheets.HPageBreaks.Add( Sheet.Range['A25'] );

should work

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Can't get it working fine...

Here's my code:
------------------------
var
vXLApp, vXLBook,
vXLTab, vXLSheets: OleVariant;
sRange: String;
begin
vXLApp := CreateOleObject('Excel.Application');
vXLBook := vXLApp.Workbooks.Open(sFile);
vXLTab := vXLBook.WorkSheets[sSheet]
vXLSheets := vXLApp.Sheets;
vXLSheets.HPageBreaks.Add(vXLTab.Range['A66']);
end;
------------------------

No exception is generated but all the code executed after the page break results in a delay about 3 times longer than without a page break insertion...

Rej Cloutier
 
Hi,

I found something here... Default Printer from Network (Local Printer is quick as it's supposed to be)

It's not the HPageBreaks.Add call that is slow but the next Range.Value affectation. The same amount of time is required when modifying only the style of a cell
(Font Name/Size/Bold).

It seems that Excel needs to talk with the network printer (does it really talks or just faking?) each call after HPageBreaks.Add...

Is there any way to manipulate an excel file without checking the state of the default printer (kind of disconnect)?

Thanks for help,

RC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top