Bonjour,

Quand je compile mon projet une erreur apparait : [Error] Excel.pas(34) : Identifier redeclared : Excel alors que je ne pense pas avoir redéclaré quoi que ce soit.
Je vous mets le code où apparaît l'erreur :


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
60
61
62
63
64
65
66
67
68
69
70
71
72
 
unit Excel;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleServer, Excel97, ComObj, StdCtrls;
 
type
  Texcel = class
  procedure Creer(nom : string);
  procedure Ouvrir(fichier : string);
  procedure Ecrire(lig:integer ; col:integer; text:string);
  procedure Fermer;
 
  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;
 
var
  Excel : Texcel; 
  OleApplication : variant;
  OleWorkbook : variant;
 
implementation
 
{$R *.dfm}
 
{******************** Crée un fichier excel ***********************************}
 
  procedure Texcel.Creer(nom : string);
  begin
    OleApplication:=CreateOleObject('Excel.Application');
    OleApplication.Visible:=false;
    OleWorkbook:=OleApplication.workBooks.Add;
    OleApplication.ActiveWorkBook.SaveAs('C:\excel\'+nom+'.xls');
    OleApplication.Quit;
    OleApplication:=Unassigned;
  end;
 
{******************** Ouvre un fichier excel **********************************}
 
  procedure Texcel.Ouvrir(fichier : string);
  begin
    OleApplication:=CreateOleObject('Excel.Application');
    OleApplication.Visible:=true;
    OleWorkBook:=OleApplication.WorkBooks.Open(Fichier);
  end;
 
{********************* Ecrire dans un fichier excel****************************}
 
  procedure Texcel.Ecrire(lig:integer ; col:integer; text:string);
  begin
    OleApplication.cells[lig,col].value:=text;
  end;
 
{********************* Ferme un fichier excel *********************************}
 
  procedure Texcel.Fermer;
  begin
    try
      OleApplication.ActiveWorkBook.Save;
      OleApplication.Quit;
      OleApplication:=Unassigned;
    except
    end;
  end;
 
end.
Je mets en effet dans var Excel : Texcel; car j'appelle ma procedure Texcel.Creer(nom : string); dans une autre Unit donné ci aprés.
J'appelle ma procédure dans NouvelleExperience.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
60
 
unit Exp;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, StdCtrls, jpeg, ExtCtrls, OleServer, Excel2000, Excel;
 
type
  TForm1 = class(TForm)
    Button1: TButton;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    GroupBox1: TGroupBox;
    Fichier1: TMenuItem;
    Nouvelleexprience1: TMenuItem;
    Quitter1: TMenuItem;
    TMainMenu: TMainMenu;
    Button3: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Image1: TImage;
    Image2: TImage;
    N1: TMenuItem;
    procedure Quitter1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Nouvelleexprience1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Quitter1Click(Sender: TObject);
begin
        close;
end;
 
procedure TForm1.Button3Click(Sender: TObject);
begin
        close;
end;
 
procedure TForm1.Nouvelleexprience1Click(Sender: TObject);
var nom : string;
begin
        Excel.Creer(nom);
end;
 
end.
Je précise que je travaille sous Delphi 6 sous Windows 2000.
Je n'arrive pas à trouver pourquoi et si quelqu'un avait une idée, cela m'aiderait beaucoup.

Merci d'avance