Retroalimentando el problema.
He hecho una prueba simple.
1.- Programa simple que invoca a excel y crea un archivo CON SERVERS, finalmente se cierra de forma automática.
Código Delphi
[-]...
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
EApp: TExcelApplication;
EWs: TExcelWorksheet;
EWb: TExcelWorkbook;
procedure FormCreate(Sender: TObject);
private
public
end;
var
Form1: TForm1;
...
procedure TForm1.FormCreate(Sender: TObject);
begin
EApp.Connect;
EApp.Visible[0] := True;
EWb.ConnectTo(EApp.Workbooks.Add(EmptyParam,0));
EWb.ConnectTo(EApp.Workbooks.Add(EmptyParam,0));
EWs.ConnectTo(EApp.Sheets[1] as _WorkSheet);
EWb.SaveAs(ExtractFilePath( Application.ExeName ) + Edit1.Text,
-4143 , emptyParam , emptyParam, false, false,
1, emptyParam, false, emptyParam, emptyParam,
emptyParam, 0);
EApp.Quit;
EApp.Disconnect;
Application.Terminate;
end;
end.
2.- Programa simple que invoca a excel y crea un archivo con automatización, finalmente se cierra de forma automática.
Código Delphi
[-]procedure TForm1.FormCreate(Sender: TObject);
var
Excel : OleVariant;
WrkB, WrkS : OleVariant;
begin
try
try
Excel := GetActiveOleObject('Excel.Application');
except
Excel := CreateOleObject('Excel.Application');
end;
Excel.DisplayAlerts := True;
Excel.Visible := True;
WrkB := Excel.Workbooks.Add;
WrkB.SaveAs(ExtractFilePath(Application.ExeName) + Edit1.Text);
finally
Excel.Quit;
Excel := Unassigned;
WrkS := Unassigned;
WrkB := Unassigned;
end;
Application.Terminate;
end;
LOS DOS FUNCIONAN cuando los programo como tareas planificadas.
Ya no sé por dónde pegarle, estoy más confundido que antes...
Saludos