unit ContForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, OleCtnrs;
type
TForm1 = class(TForm)
OleContainer1: TOleContainer;
Panel1: TPanel;
Button1: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
procedure TForm1.Button1Click(Sender: TObject);
var
Document: Variant;
begin
if not (OleContainer1.State = osRunning) then
OleContainer1.Run;
Document := OleContainer1.OleObject;
Document.Paragraphs.Item(1).Range.Bold := 1;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
Document, Paragraph: Variant;
begin
if not (OleContainer1.State = osRunning) then
OleContainer1.Run;
Document := OleContainer1.OleObject;
Document.Paragraphs.Add;
Paragraph := Document.Paragraphs.Add;
Paragraph.Range.Font.Size := 10 + Random (20);
Paragraph.Range.Text := 'New text (' +
IntToStr (Paragraph.Range.Font.Size) + ')'#13;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
end;
end.
|