Delphi Word Automation:如何在表格后插入文本? [英] Delphi Word automation: how to insert text after a table?

查看:192
本文介绍了Delphi Word Automation:如何在表格后插入文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带表的Microsoft Word文档。我的问题是我需要在表后添加一些文本,但是当我在表后使用 Selection.TypeText(Text)时,文本将显示在表内部,而不是在表后/表外桌子。
如何在表格后插入文本?

I have a Microsoft Word document with a table in it. My problem is that I need some text after the table but when I use Selection.TypeText(Text) after the table, the text is shown inside the table and not after/outside the table. How can I insert text after the table?

下面显示的代码:

Table := MSWord.ActiveDocument.Tables.Add(MSWord.Selection.Range, 2, 1);
Table.Cell(1, 1).Range.Text := 'GreenDay';
Table.Cell(2, 1).Range.Text := 'Kiss';
MSWord.Selection.TypeText('cdassda');

我的第二个问题是我无法将数据追加到新页面:

My second problem is that I am not able to append data to a new page:

MSWord.Selection.Goto(wdGoToPage, wdGoToLast);


推荐答案

尝试一下:

Table.Cell(1, 1).Range.Text := 'GreenDay';
Table.Cell(2, 1).Range.Text := 'Kiss';
MSWord.Selection.EndKey( Unit:=wdStory);
MSWord.Selection.TypeParagraph;
MSWord.Selection.TypeText('cdassda');

关于第二点,这对我有用:

Regarding your second point, this works for me:

//MSWord.Selection.Goto(wdGoToPage, wdGoToLast);

MSWord.Selection.EndKey( Unit:=wdStory );
MSWord.Selection.InsertBreak( Type:=wdPageBreak);

MSWord.Selection.TypeText('next page');

这篇关于Delphi Word Automation:如何在表格后插入文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆