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: Di 29.03.05 15:10 
Hallo!
Ich arbeite mit einer Exceldatei, die ich so lade:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
{Übergabe an Excel}
procedure Texcelab.eexcel;
begin
 try
    ExcelApp := GetActiveOleObject('Excel.Application');
     except
    try
       ExcelApp := CreateOleObject('Excel.Application');
    except
      application.messagebox ('Excel ist nicht installiert!','Fehler',16);
      Exit;
    end;
  end;
   ExcelApp.visible:=false;
  // Open a Workbook, Arbeitsmappe öffnen
  ExcelApp.Workbooks.Open('C:\test'{Siehe Frage 1}'\Test.XLS');


Die Probleme sind folgendermaßen:
1) Ich möchte, dass Excel die Datei Test.xls aus dem Verzeichniss startet, wo auch das Hauptprogramm ist.
2) Die Test.xls ist Passwort geschützt. Wie kann ich die trozdem öffnen?
Danke1
fvolk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 203

Win XP (Home & Pro)
Delphi 2005 Pers
BeitragVerfasst: Di 29.03.05 15:45 
Das Verzeichnis, in dem dein Hauptprogramm ist, findest du mit Hilfe Variablen Application.ExeName. In dieser ist der Dateiname deines Programmes gespeichert.
Mit ExtractFileDir holst du dir nur den Ordner und mit IncludeTrailingPathDelimiter packst du ein eventuell noch fehlendes (Back)slash dazu:

ausblenden Delphi-Quelltext
1:
ExcelApp.Workbooks.Open(IncludeTrailingPathDelimiter(ExtractFileDir(Application.ExeName)) + 'test.xls');					


Natürlich kannst du die Excel-Datei öffnen, du musst nur das Passwort kennen. :wink:
Mal ehrlich, wäre doch ziemlich dumm von den Entwicklern bei Microsoft, wenn das OLEObject, das sie selbst rausgeben, den Passwortschutz umgehen könnte.

_________________
Nichts auf der Welt ist so gerecht verteilt wie der Verstand. Denn jedermann ist überzeugt, dass er genug davon habe.
(René Descartes)
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: Di 29.03.05 15:48 
Hallo!
Mir ist das Passwort natürlich bekannt. Ich will ja nur, dass die OLE Automation das Passwort eingibt!
fvolk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 203

Win XP (Home & Pro)
Delphi 2005 Pers
BeitragVerfasst: Do 31.03.05 10:47 
Hab's gefunden:

In folgendem Artikel www.delphipages.com/tips/thread.cfm?ID=189 (den mir Google gesucht und gefunden hat), wird beschrieben, wie man eine passwortgeschützte Datei öffnet (und ohne Passwort wieder speichert). Kurz gesagt: Das Passwort wird bei Open einfach als zweiter Parameter übergeben.

_________________
Nichts auf der Welt ist so gerecht verteilt wie der Verstand. Denn jedermann ist überzeugt, dass er genug davon habe.
(René Descartes)
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: Sa 02.04.05 09:19 
Hallo!
Danke für den Tip! Genau das habe ich gesucht. Aber eine Frage hätte ich doch noch zu Excel: Gibt es irgeneine Möglichkeit durch OLE auch noch ein bestimmtes Makro zu starten?
Danke!
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: Sa 02.04.05 11:13 
Habs jetzt selber rausgefunden:

ausblenden Delphi-Quelltext
1:
Excelapp.run('MeinMakro1');