Re: directly print .doc .xls with Delphi


[ DelphiLand FAQ ]

Posted by Giovanni Caramia on April 29, 2004 at 02:31:52:

In Reply to: Re: directly print .doc .xls with Delphi posted by Giovanni Caramia p12316 on April 27, 2004 at 08:18:06:

At least i solved in some manner:

uses comobj;
procedure TForm1.Button1Click(Sender: TObject);
  var MyExcel: olevariant;
begin
  MyExcel:=UnAssigned;
  MyExcel:=CreateOleObject('Excel.Application');
  Try
    MyExcel.Visible:=false; 
    MyExcel.WorkBooks.open('..\cartel1.xls');
    MyExcel.WorkSheets.Printout;
  Finally
    if not varisempty(MyExcel) then
    begin
      MyExcel.quit;
      MyExcel := unassigned;
    end;
  end;
end;

If default printer is either Acrobat Distiller or any Postscript Printer + GostScript + FreeDist a .pdf is generated.

If you have any suggestion in addition i shall appreciate.
Thanks Guido


DelphiLand FAQ