Autor Beitrag
lexmy3
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

WIN 2000 Prof. + Office 2000
Delphi 5 Enterprise
BeitragVerfasst: Di 07.03.06 13:51 
Hallo ich möchte eine ExcelVorlage laden und es klappt beinah, jedoch wird das Excel Arbeitsblatt nicht angezeigt nur in der Druckansicht.

Ich sehe nur die Arbeitsleisten Oben und Unten aber nicht das Arbeitsblatt von Excel.

Was mache ich falsch???
ausblenden Delphi-Quelltext
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:
 
// VORLAGE LADEN
procedure TForm1.Button4Click(Sender: TObject);
var
   ExcelVorlage : OleVariant;
   sValue : String;
begin
     try
         ExcelVorlage:= ('C:\test.xls');

         flcid:=GetUserDefaultLCID;
         ExcelApplication1.Connect;
         ExcelApplication1.Visible[flcid]:=true;
         ExcelApplication1.UserControl:=true;

         ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Add(ExcelVorlage,flcid));

         ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Sheets.Item[1as ExcelWorkSheet);
         sValue:=ExcelWorksheet1.Range['B1','B1'].Value;

         ExcelWorksheet1.Disconnect;
     Finally

         ExcelApplication1.Disconnect;

end;
   end;
end.
lexmy3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 140

WIN 2000 Prof. + Office 2000
Delphi 5 Enterprise
BeitragVerfasst: Di 07.03.06 14:37 
Titel: Excel als Vorlage benutzen!!!
Hey habe das Problem gelöst. :lol:

hier der vollständige Code, dieser funktioniert:

ausblenden Delphi-Quelltext
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:
procedure TForm1.Button4Click(Sender: TObject);
var
   flcid: DWord;
   ExcelVorlage : OleVariant;
   sValue : String;
begin
     try
     ExcelVorlage := ('C:\ExcelEnglish\Condition.xlt'); // Pfad angeben!!!

     flcid:=GetUserDefaultLCID;
     ExcelApplication1.Connect;
     ExcelApplication1.Visible[flcid]:=true;
     ExcelApplication1.UserControl:=true;

     ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Add(ExcelVorlage,flcid));

     ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Sheets.Item[1as ExcelWorkSheet);
     sValue:=ExcelWorksheet1.Range['B1','B1'].Value;

     ExcelWorksheet1.Disconnect;
Finally

     ExcelApplication1.Disconnect;
     Application.Terminate;
         end;
              end;