2011-12-01 41 views
0

我自動化用Delphi 2010德爾福2010:在Word表格多行內容

在佈局我有,我需要插入一行文本到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; 

我甚至不能創建水平線宏(這必須和詳細的尺寸和重量)的VBA在Word 2010將不會從右鍵單擊記錄...

回答

0

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

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

它發送一個「結束」信號到Word。

至於錄製新的水平線,我發現在某些情況下,Windows鍵盤上的上下文菜單鍵仍然適用於錄製宏,而右鍵單擊不支持。