0

我正在使用 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 不会通过右键单击记录...

4

1 回答 1

0

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

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

它向 Word 发送“结束”信号。

As for recording the new Horizontal Line, I found that in some situations the Context Menu Key on a Windows Keyboard still works when recording macros, where Right Click does not.

于 2011-12-06T11:10:00.413 回答