【问题标题】:Delphi Word automation: how to insert text after a table?Delphi Word 自动化:如何在表格后插入文本?
【发布时间】:2015-12-05 11:13:40
【问题描述】:

我有一个包含表格的 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);

【问题讨论】:

    标签: delphi


    【解决方案1】:

    试试这个:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-16
      • 1970-01-01
      相关资源
      最近更新 更多