1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OleCtnrs, Menus;
type
TForm1 = class(TForm)
oc_word: TOleContainer;
MainMenu1: TMainMenu;
Fichier1: TMenuItem;
Ouvrirlefichierword1: TMenuItem;
Fermerlefichierword1: TMenuItem;
procedure FormActivate(Sender: TObject);
procedure Ouvrirlefichierword1Click(Sender: TObject);
procedure Fermerlefichierword1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormActivate(Sender: TObject);
begin
oc_word.Align := alClient;
end;
procedure TForm1.Ouvrirlefichierword1Click(Sender: TObject);
begin
oc_word.CreateObjectFromFile(ExtractFilePath(ParamStr(0)) + 'mondoc.doc',False);
oc_word.Doverb(ovPrimary);
//Pour corriger un bug qui fait mal se positionner les barres d'outils j'agrandis de 1 ma fenêtre
Height := Height + 1;
oc_word.OleObject.Application.ScreenUpdating := False;
//J'efface l'image 1 du document
oc_word.OleObject.Application.ActiveDocument.InlineShapes.Item(1).Delete;
oc_word.OleObject.Application.ScreenUpdating := True;
end;
procedure TForm1.Fermerlefichierword1Click(Sender: TObject);
begin
try
oc_word.Close;
oc_word.DestroyObject;
except
oc_word.DestroyObject;
end;
end;
end. |
Partager