Вот вроде наиболее оптимальный вариант решения.
| Код | var Rng: Range; MSWord : TWordApplication; VR : OleVariant; ST : TStringList; I, J : Integer; S : string;
begin ST := TStringList.Create; for I := 1 to 1000 do begin S := ''; for J := 1 to 50 do begin if Length(s) > 0 then S := S + ','; S := S + IntToStr(J); end; ST.Add(S); end;
Try MsWord := TWordApplication.Create(Self); MsWord.Connect; MsWord.Visible := False; MsWord.Documents.Add(EmptyParam, EmptyParam, EmptyParam, EmptyParam);
Rng := MsWord.Selection.Range; VR := wdCollapseEnd; Rng.Collapse(VR); Rng.InsertAfter(St.Text); VR := ','; Rng.ConvertToTable(VR , EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam);
MsWord.Visible := True; MsWord.Disconnect; Finally MsWord.Free; end; St.Free; end;
|
|