Autor Beitrag
hibbert
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Sa 27.12.03 00:07 
Hi,
ich wollte mal fragen bzw. wissen, ob es möglich ist, eine Microsoft Excel Datei (nicht passwort gesichert) mit Delphi auszudrucken, ohne diese Datei zu öffen. Jedenfalls so, dass der User nicht bemerkt, dass diese Datei geöffnet wird.

ist das möglich? wenn ja wie ??

thx hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Sa 27.12.03 07:09 
Hi,

z.b so

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
uses 
  ComObj;

var
  xls: OLEVariant;
begin
  xls := CreateOleObject('Excel.Application');
  try
    xls.Visible := False;
    xls.Workbooks.Open('ExcelDatei.xls');
    ActiveWorkBook.Print;
  finally
    xls.Quit;
    xls:=unassigned;
  end;
hibbert Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Sa 27.12.03 15:52 
Danke, doch ioch erhalte beim compelieren diese Fehlermeldung:
Compiler hat folgendes geschrieben:
[Fehler] Unit1.pas(35): Undefinierter Bezeichner: 'ActiveWorkBook'


Was nun?

hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
hibbert Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Sa 27.12.03 16:09 
ok, das hab eihc jetzt doch noch hinbekommen, aber nun erhalte ich diese Fehlermelung beim ausführen:
Zitat:
---------------------------
Benachrichtigung über Debugger-Exception
---------------------------
Im Projekt Project1.exe ist eine Exception der Klasse EOleError aufgetreten. Meldung: 'Die Methode 'Print' wird vom Automatisierungsobjekt nicht unterstützt'. Prozess wurde angehalten. Mit Einzelne Anweisung oder Start fortsetzen.
---------------------------
OK Hilfe
---------------------------

Mein Quelltext sieht jetzt so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.Button1Click(Sender: TObject);
var  xls: OLEVariant;
begin
if opendialog1.Execute= true then
begin
  xls := CreateOleObject('Excel.Application');
  try
    xls.Visible := False;
    xls.Workbooks.Open(opendialog1.FileName);
    xls.ActiveWorkBook.Print;
  finally
    xls.Quit;
    xls:=unassigned;
  end;
end;
end;


thx hibbert

Moderiert von user profile iconPeter Lustig: Code- durch Delphi-Tags ersetzt

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: So 28.12.03 09:50 
Probier's mal so:

xls.ActiveWorkBook.PrintOut;
hibbert Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: So 28.12.03 10:46 
cool Danke !!

thx hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
Skorsi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Di 09.03.04 15:11 
Hallo,

wie kann man damit auch Word Dokumente drucken?
Was muss geändert werden außer Application.Word?

Gruß, skorsi
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Do 11.03.04 21:24 
Zitat:
wie kann man damit auch Word Dokumente drucken?
Was muss geändert werden außer Application.Word?


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
uses
  ComObj;

procedure TForm1.Button1Click(Sender: TObject);
var
  wordapp: OLEVariant;
begin
  if OpenDialog1.Execute then
  begin
    wordapp := CreateOleObject('Word.Application');
    try
      wordapp.Visible := False;
      wordapp.Documents.Open(OpenDialog1.FileName);
      wordapp.PrintOut;
    finally
      wordapp.Quit;
      wordapp:=Unassigned;
    end;
  end;
end;