Inserting a page break in Excel

How can insert a page break in excel from Navision. I have tried with sheet.HpageBreaks But its gives an error. Any idea ?? Regards

Hi! You used wrong syntax. Try this one: <------------------------------------------------------------------> var xlRange Automation MS Excel Range var xlHPageBreaks Automation MS Excel HPageBreaks var xlHPageBreak Automation MS Excel HPageBreak var xlWorksheet Automation MS Excel xlWorksheet xlRange := xlWorksheet.Range(‘C10’) // For example xlHPageBreaks := xlWorksheet.HPageBreaks; xlHPageBreak := HPageBreaks.Add(xlRange); <------------------------------------------------------------------> You’ll get horizontal page break before xlRange element

… or even shorter: xlRange := xlWorksheet.Range(‘C10’) // For example xlRange.PageBreak := -4135; Marcus Fabian phone: +41 79 4397872 m.fabian@thenet.ch

Both the codes are working. But it gives both horizontal and vertical page breaks. But the requirement is only Horizontal and sometimes only vertical. How ? Hi constis please note that HPageBreaks is not declared. declared variable is xlHPageBreak so rewrite the line xlHPageBreak := HPageBreaks.Add(xlRange); As xlHPageBreak := xlHPageBreaks.Add(xlRange); Thanks.

------- rewrite the line xlHPageBreak := HPageBreaks.Add(xlRange); As xlHPageBreak := xlHPageBreaks.Add(xlRange); ----- Of course my misprint. You’ll get vertical break without any your participation. Because MS Excel make it himself. You can only delete this vertical break or move it. The variables declaration and code is similar with the horizontal break case. Best regards, Const.

Hi,

i have a similar problem when not actually the same one. I’ve tried out both of the solutions you’ve posted above. Unfortunately it brought not the effect which i ecpected. Both of the functions make a “Page Break”, although I need a “Line Break” in a Cell. I mean I need the same effect as (Alt + Enter) does, inside a Cell. The reason is following.

For Example I have to print this in one Cell:

Month: July
“line break”
Year: 2007

So the question is, does anyone know how I could solve this Problem?

Best Regards,
Nokio85

Does no one know the solution? Its really urgent…

ActiveCell.FormulaR1C1 = “Data1” & Chr(10) & “Data2”

Thtats the exact Excel Makro, but it doesn’t really work.

But I could solve the problem:

The solution is following:

New Function:

LineBreak() NL : Text[30]

(Variable)
Char10 := 10;

(Return Variable)
NL := FORMAT(Char10);

Just use NL as a Line Break, works perfectly.