Delphi 2010:Multiline content in Word Table
I'm automating some document creation using Delphi 2010.
In the layout I have, I need to insert one line of text into a Word table cell (1, 1), then move to the next line, change the paragraph settings, and insert a horizontal rule
I can setup the table and the first line content, but cannot for the life of me work out how to move the cursor to the second line of the cell, or insert the horizontal line
What I have so far:
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;
I cannot even create a macro for the Horizontal line (which needs to be and exact size and weight) as VBA in Word 2010 won't record from right-clicks...
So the code I needed to do the new line was as follows
seltype := wdLine; lineextend := False; WordApp.Selection.EndKey(seltype, lineextend); WordApp.Selection.TypeParagraph;
Which sends an "End" signal to 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.