gpt4 book ai didi

Delphi Word自动化: how to insert text after a table?

转载 作者:行者123 更新时间:2023-12-02 13:30:57 24 4
gpt4 key购买 nike

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

代码如下:

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');

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

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');

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

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

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

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

关于Delphi Word自动化: how to insert text after a table?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34104173/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com