Board index » delphi » Problem with pageBreake in Word.

Problem with pageBreake in Word.


2003-09-03 04:29:23 PM
delphi264
What I want to do is to
insert a table. and then create a page breake after this table and then add
a second document.
My table always dissapear when I try to insert the page breake.
Here is a pice of my code
if Node.Count>0 then
begin
for ix:= 0 to Node.Count-1 do
begin
RichEdit1.Clear;
RichEdit1.Lines.LoadFromStream(RTFHelper.StrToStream(TMyObj(Node[ix].Data).T
ext));
TmpStr2:= Trim(RichEdit1.Lines.Text);
TmpStr:= TObj(Node[ix].Data).TermDescr+ '|' + TmpStr2;
R.InsertAfter(TmpStr);
R.InsertParagraphAfter;
end;
Separator := '|';
Format := wdTableFormatSimple1;
AutoFit:= wdTableFormatApplyAutoFit;
Tbl:= R.ConvertToTableOld(Separator, EmptyParam, EmptyParam,
EmptyParam, Format, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, AutoFit);
Tbl.Columns.First.Width:= 150;
Tbl.Rows.First.Borders.Item(wdBorderBottom).LineStyle :=wdLineStyleNone;
Tbl.Rows.First.Borders.Item(wdBorderTop).LineStyle :=wdLineStyleNone;
Tbl.Rows.Last.Borders.Item(wdBorderBottom).LineStyle :=wdLineStyleNone;
Tbl.Rows.Last.Borders.Item(wdBorderTop).LineStyle :=wdLineStyleNone;
end;
Wordapp.ActiveDocument.Activate;
WordApp.ActiveDocument.Select;
oBreak:= wdPageBreak;
WordApp.Selection.InsertBreak(oBreak);
Wordapp.ActiveDocument.Activate;
Doc2:= WordApp.Documents.AddOld(Fname2,EmptyParam);
Doc2.Activate;
WordApp.ActiveDocument.Select;
Doc2.Content.Copy;
Dest := Doc1.Content;
Direction := wdCollapseEnd;
Dest.Collapse(Direction);
Dest.Paste;
 
 

Re:Problem with pageBreake in Word.

Just use
R.InsertBreak(wdPageBreak)
instead next lines:
oBreak:= wdPageBreak;
WordApp.Selection.InsertBreak(oBreak);
PS: as I understand fromy our code, R is a document range. Yes?
"Magnus Holmberg" <XXXX@XXXXX.COM>сообщи?сообщила ?новостях
следующе? news:XXXX@XXXXX.COM...
Quote
What I want to do is to

insert a table. and then create a page breake after this table and then
add
a second document.
My table always dissapear when I try to insert the page breake.

Here is a pice of my code

if Node.Count>0 then
begin
for ix:= 0 to Node.Count-1 do
begin
RichEdit1.Clear;


RichEdit1.Lines.LoadFromStream(RTFHelper.StrToStream(TMyObj(Node[ix].Data).T
ext));
TmpStr2:= Trim(RichEdit1.Lines.Text);
TmpStr:= TObj(Node[ix].Data).TermDescr+ '|' + TmpStr2;
R.InsertAfter(TmpStr);
R.InsertParagraphAfter;
end;
Separator := '|';
Format := wdTableFormatSimple1;
AutoFit:= wdTableFormatApplyAutoFit;
Tbl:= R.ConvertToTableOld(Separator, EmptyParam, EmptyParam,
EmptyParam, Format, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam,
EmptyParam, AutoFit);

Tbl.Columns.First.Width:= 150;
Tbl.Rows.First.Borders.Item(wdBorderBottom).LineStyle
:=wdLineStyleNone;
Tbl.Rows.First.Borders.Item(wdBorderTop).LineStyle :=wdLineStyleNone;
Tbl.Rows.Last.Borders.Item(wdBorderBottom).LineStyle
:=wdLineStyleNone;
Tbl.Rows.Last.Borders.Item(wdBorderTop).LineStyle :=wdLineStyleNone;
end;
Wordapp.ActiveDocument.Activate;
WordApp.ActiveDocument.Select;
oBreak:= wdPageBreak;
WordApp.Selection.InsertBreak(oBreak);


Wordapp.ActiveDocument.Activate;
Doc2:= WordApp.Documents.AddOld(Fname2,EmptyParam);
Doc2.Activate;
WordApp.ActiveDocument.Select;
Doc2.Content.Copy;
Dest := Doc1.Content;
Direction := wdCollapseEnd;
Dest.Collapse(Direction);
Dest.Paste;


 

Re:Problem with pageBreake in Word.

I'd try moving your cursor to the end of the document first, I would guess whats
happening is its trying to insert the pagebreak inside a cell of the table,
and causing some bother. I am not sure hwat the code for this is, but record
a macro in word while you do it yourself and you will find our the VB(Visual Basic) code.
hope this helps
Toby Allen.
"Magnus Holmberg" <XXXX@XXXXX.COM>writes
Quote
What I want to do is to

insert a table. and then create a page breake after this table and then
add
a second document.
My table always dissapear when I try to insert the page breake.