Buenas les pediria cierta ayuda
Estoy haciendo un programa muy básico para con conección con Excel y me da un error al salvarlo en procedimiento en concreto es este:
Procedure TForm2.Button1Click(Sender: TObject); {boton de validar la factura}
var
OleApli,OleWB : Variant;
PrecioKwatio , Importe:real;
Valor:string;
Nombre_archivo :String;
i:Integer;
begin
assignfile(Arch_NFactura,'c:\Facturas\NFactura.txt');
Append(Arch_NFactura);
assignfile(Arch_Tarifa,'c:\Facturas\Tarifa.txt');
reset(Arch_Tarifa);
Factura.Visible:=False;
Importe:=StrtoFloat(NFactura);
Importe:=Importe+1;
NFactura:=FloattoStr(Importe);
writeln (Arch_NFactura,NFactura);
writeln (Arch_NFactura,FechaEmision);
writeln (Arch_NFactura,mes);
writeln (Arch_NFactura,agno);
writeln (Arch_NFactura,LecturaActual);
writeln (Arch_NFactura,LecturaAnterior);
PeriodoFactura:=(mes+'-'+agno);
Edit1.Enabled:= False;
Edit2.Enabled:= False;
Edit3.Enabled:= False;
Edit4.Enabled:= False;
Edit5.Enabled:= False;
OleApli := CreateOleObject('Excel.Application');
OleApli.Visible:=true;
OleWB := OleApli.Workbooks.open('c:\Facturas\Modelo Factura numero 000.xls');
OleApli.Cells[19,7]:= NFactura;
OleApli.Cells[19,9]:= FechaEmision;
OleApli.Cells[42,5]:= PeriodoFactura;
OleApli.Cells[37,8]:= LecturaActual;
OleApli.Cells[36,8]:= LecturaAnterior;
OleApli.Cells[44,4]:= Tarifa;
Importe:= OleApli.Cells[52,8];
Valor:= floattoStrf(Importe,ffCurrency,8,2);
writeln (Arch_NFactura,Valor);
Closefile (Arch_NFactura);
{------------------ es aquí donde me da el error al salvarlo ----------------}
OleApli.ActiveWorkBooks.saveAs('c:\Facturas numero 0'+NFactura+'.xls');
{-------------------------------------------------------------------------}
Edit1.Text:=NFactura;
Form2.Visible:=False;
Form4:=TForm4.Create(self);
Form4.caption:='Factura '+(NFactura);
Form4.show;
end;
{-------------------------------------------------------------------------------}
lo cierto es que no doy con el error, si alguien puede ayudar se lo agradecería.
Saludos
|