Ver Mensaje Individual
  #20  
Antiguo 22-04-2009
fsolispa fsolispa is offline
Miembro
 
Registrado: sep 2008
Posts: 28
Reputación: 0
fsolispa Va por buen camino
Cita:
Empezado por fsolispa Ver Mensaje
Muchas gracias.
Ya realice las modificaciones necesarias de acuerdo a la información que me diste y trabaja super bien, no utilice el comando

Try
Excel := GetActiveOleObject('Excel.Application')
Except
Excel := CreateOleObject('Excel.Application')
End;

ya que me daba error al leer, entonces lo solo cree, como no creare un nuevo archivo de excel solo utilice los comandos necesarios que fueron

Libro := Excel.WorkBooks.Open(sArchivo);
xlSheet := Libro.WorkSheets.Item[sShetName);

Dentro de un if para determinar la hoja de excel en la que se guardará la información y un while para llenarla el programa quedo así

procedure TGeneraListasFrm.SpeedButton2Click(Sender: TObject);
Var
Excel, Libro, Hoja : Variant;
i : integer;
begin
i := 7;
Excel := CreateOleObject('Excel.Application');
Libro := Excel.WorkBooks.Open('E:\Mis Documentos\feb08.xls');
if ModuloDatosFrm.ZListaQrycgrado.Value = 'PREP01' then
Begin
Hoja := Libro.WorkSheets.Item[6];
With ModuloDatosFrm.ZListaQry Do
Begin
First;
while not EOF do
Begin
i := i + 1;
Hoja.Cells.Item[i,1] := DbGrid1.Fields[0].AsString;
Next;
End;
End;
Excel.Visible := True;
End
Else if ModuloDatosFrm.ZListaQrycgrado.Value = 'PREP02' then
Begin
Hoja := Libro.WorkSheets.Item[7];
With ModuloDatosFrm.ZListaQry Do

bueno y continua hasta 'PREP06'
Responder Con Cita