Autor Beitrag
bigmasterdenis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 48



BeitragVerfasst: Di 16.12.08 17:25 
Hi Leute,

um eine excel datei zu laden mache ich folgendes:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
excel.Connect;
excel.Visible[GetUserDefaultLCID] := false;
excel.UserControl := True;
excel.Workbooks.Open(filename, False, False, EmptyParam, '', False, False, EmptyParam, EmptyParam, false, false, EmptyParam, false, 0);


Da die Datei im Hintergrund bearbeitet werden soll, setze ich Sichtbarkeit in Zeile 2 auf false. Das Problem ist nur, dass auch andere offene Excel-Dateien unsichtbar werden. Gibt es eine Möglichkeit nur das aktive WorkBook auszublenden?

thanks for help

Moderiert von user profile iconNarses: Code- durch Delphi-Tags ersetzt
rd3
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 16.12.08 18:13 
vielleicht so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure SetVisibility(bVisible: Boolean);
var
  OleVisible: OleVariant;
begin
  OleVisible := bVisible;
  excel.ActiveWorkbook.Sheets.Visible[idx] := OleVisible;
end;


gruss
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 17.12.08 02:31 
Das ändert ja nur die Sichtbarkeit der einzelnen Sheets im Workbook. (Geht das überhaupt? Nie probiert :D)

Zum Problem:
Hast du ConnectKind auf ckNewInstance gesetzt? Weil eine neue Instanz sollte ja unabhängig von den bisherigen sein. Standardmäßig ist dieser Wert nämlich ckRunningOrNew.
bigmasterdenis Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 48



BeitragVerfasst: Mi 17.12.08 17:24 
Zitat:

Hast du ConnectKind auf ckNewInstance gesetzt? Weil eine neue Instanz sollte ja unabhängig von den bisherigen sein. Standardmäßig ist dieser Wert nämlich ckRunningOrNew.


Hmm... nicht, dass ich wüsste. Was für ein ConnectKind? Wie genau setze ich denn das Zeug auf ckNewInstance?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 17.12.08 18:02 
ausblenden Delphi-Quelltext
1:
2:
3:
excel.ConnectKind := ckNewInstance;
excel.connect;
...
Oder wenn du es auf dem Formular hast als Komponente gehts auch schon im Objektinspektor. :D