Autor Beitrag
ebs
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 213

Suse Linux 9.2, Win 98, Win NT, Win XP, Win for Workgroups, Win XP SP2, Dos 6.1
D3 Prof, D2005 PE, Delphi 2006 Prof.
BeitragVerfasst: Mi 27.04.05 17:47 
Hallo!
Ich greife per OLE auf ein Exceldatei zu. Dabei wird dann eine Schleife in meinem Programm durchgeführt, die genau hundert mal durchaufen wird, und dann Zahlen in die Exceldatei schreibt. Außerdem wird der Zustand der Rechnung auf einer Progessbar angezeigt, indem ich nach jeder Rechnung progessbar.position:=progessbar.position+1 mache. Das Problem ist jetzt nur, dass das mit der Progessbar nur einmal klappt. Die Schleife wird ausgeführt, Excel startet, fügt die Werte ein, doch die Progressbar kommt einfach nicht vorwärts. Erst wenn die Schleife hundertmal durchlaufen wurde springt die Progessbar sofort auf hundert. Meine Frage ist nun, ob es irgendeine Möglichkeit gibt die Exceldatei während des Zugriffs zu sperren. Und zwar ist meine Exceldatei Passwort geschützt, doch wenn ich auf die Datei zugreife öffnet sich frölich Excel, und fragt, ob ich die Datei wirklich nochmal öffnen will, und ich kann ohne Passwort darauf zugreifen. Ich hoffe Ihr könnt mir helfen.
Danke!

Hier noch ein Fereinfachter Code:
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:
29:
30:
procedure TTherm.eexcelstarten;

begin
 try
    ExcelApp := GetActiveOleObject('Excel.Application');
     except
    try
       ExcelApp := CreateOleObject('Excel.Application');
           except
      application.messagebox ('Excel ist nicht installiert oder zu alt','Fehler',16);
      Exit;
    end;
    end;

   ExcelApp.visible:=false;
     // Open a Workbook, Arbeitsmappe öffnen
   ExcelApp.WorkBooks.Open(filename:=extractfiledir(Application.ExeName) + '\test.xls', Password := 'Supertest',ReadOnly := false);
end;

//Schleife
for b:=0 to 10 do begin
x[3]:=floattostr(strtofloat(y13[1])-b*Blockschritt);

for a:=0 to 10 do begin
y[5]:=floattostr(strtofloat(y13[3])-a*Durchsatzschritt);
ExcelApp.worksheets['Test'].Cells[c, 2].Value := formatfloat('0.00',strtofloat(x));
progessbar.position:=progessbar.position+1;
end;
end;
//Blockschritt und Durchsatzschritt werden voher berrechnet
ebs Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 213

Suse Linux 9.2, Win 98, Win NT, Win XP, Win for Workgroups, Win XP SP2, Dos 6.1
D3 Prof, D2005 PE, Delphi 2006 Prof.
BeitragVerfasst: Do 28.04.05 14:28 
Hallo!
Da ist mir aber ein Fehler unterlaufen. :oops:
Man muss natürlich die progessbar wieder auf Null setzen. :idea:
Aber jetzt bleibt aber noch das Problem mit der Sicherheit!
Danke! :D