【问题标题】:Delphi 2010:Multiline content in Word TableDelphi 2010:Word 表中的多行内容
【发布时间】:2011-12-01 14:28:27
【问题描述】:

我正在使用 Delphi 2010 自动创建一些文档。

在我的布局中,我需要在 Word 表格单元格 (1, 1) 中插入一行文本,然后移动到下一行,更改段落设置,并插入水平线

我可以设置表格和第一行的内容,但我一生都无法弄清楚如何将光标移动到单元格的第二行,或者插入水平线

到目前为止我所拥有的:

   tbl.Cell(1, 1).Range.Text := s;
   with tbl.Cell(1, 1).Range do
   begin
      Font.Name := '+Headings';
      Font.Size := 14;
      Font.Bold := -1;
      Font.AllCaps := -1;
      ParagraphFormat.LineSpacingRule := wdLineSpaceAtLeast;
      ParagraphFormat.LineSpacing := 12;
      ParagraphFormat.SpaceAfter := 0;
      ParagraphFormat.SpaceBefore := 0;
   end;
   tbl.Cell(1, 1).Range.InsertParagraphAfter;

我什至无法为水平线创建一个宏(它必须是精确的大小和重量),因为 Word 2010 中的 VBA 不会通过右键单击记录...

【问题讨论】:

    标签: delphi vba word-2010


    【解决方案1】:

    所以我需要做新行的代码如下

    seltype := wdLine;
    lineextend := False;
    WordApp.Selection.EndKey(seltype, lineextend);
    WordApp.Selection.TypeParagraph;
    

    向 Word 发送“结束”信号。

    关于录制新的水平线,我发现在某些情况下,Windows 键盘上的上下文菜单键在录制宏时仍然有效,而右键单击则不能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-28
      • 1970-01-01
      • 2016-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-21
      相关资源
      最近更新 更多