unit Unit_20;

interface

uses
  Windows, Messages, SysUtils,Variants,Classes, Graphics,
  Controls, Forms, Dialogs, StdCtrls, ComCtrls,
  ComObj, OleServer, MSPpt8;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    RichEdit1: TRichEdit;
    Button3: TButton;
    PowerPointApplication1: TPowerPointApplication;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}


//----------------------------------------------------------
procedure TForm1.Button2Click(Sender: TObject);
var
  PowerPointApp: OleVariant;
begin
  try
    PowerPointApp := CreateOleObject('PowerPoint.Application');
    RichEdit1.Lines.Add('PowerPoint wersja '+PowerPointApp.Version);
  except
    Application.MessageBox('PowerPoint nie jest zainstalowany.',
                           'Błąd otwarcia aplikacji', MB_OK);

  end;
end;
//----------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
begin
  PowerPointApplication1.Disconnect();
  Application.Terminate();
end;
//----------------------------------------------------------
procedure TForm1.FormCreate(Sender: TObject);
begin
    PowerPointApplication1.Connect();
end;
//----------------------------------------------------------
procedure TForm1.Button3Click(Sender: TObject);
begin
  PowerPointApplication1.Visible:=1;
end;
//----------------------------------------------------------


end.

