Ver Mensaje Individual
  #2  
Antiguo 10-02-2006
Avatar de OSKR
OSKR OSKR is offline
Miembro
 
Registrado: nov 2004
Ubicación: San Cristóbal/Táchira/Venezuela
Posts: 389
Reputación: 20
OSKR Va por buen camino
Creo recordar haber respondido esto antes pero eso fue hace mucho antes, yo uso algo asi y nada de excepciones:
Código:
//Para abrir excel
Variant xlApp;
xlApp = CreateOleObject("Excel.Application");
//hacer visible EXCEL
xlApp.Exec(PropertySet("Visible") << true);
//Acceso a un objeto libro
Variant xlBooks = xlApp.Exec(PropertyGet("Workbooks"));
//crea un nuevo archivo
xlBooks.Exec(Procedure("Add"));
//elige el primer libro de la aplicación
Variant xlBook = xlBooks.Exec(PropertyGet("Item") << 1);
//crea un acceso a un objeto hoja
Variant xlSheets = xlBook.Exec(PropertyGet("Worksheets"));
//Elige una hoja
Variant xlSheet = xlSheets.Exec(PropertyGet("Item") << 1);
//En esta parte es en donde agregas los datos
Variant VRange;
VRange = xlSheet.Exec(PropertyGet("Range") << "A4");
VRange.Exec(PropertySet("Value") << "RUT");
VRange = xlSheet.Exec(PropertyGet("Range") << "B4");
VRange.Exec(PropertySet("Value") << "NOMBRE");
int fila=5;
VRange = xlSheet.Exec(PropertyGet("Range") << "A"+IntToStr(fila));
VRange.Exec(PropertySet("Value") << Edit1->Text);
VRange = xlSheet.Exec(PropertyGet("Range") << "B"+IntToStr(fila));
VRange.Exec(PropertySet("Value") << Edit2->Text);
fila++;
//Guarda el archivo
xlBook.Exec(Procedure("SaveAs") << "\\archivo.xls");
//-------- Cierra excel
//xlApp.Exec(PropertySet("Visible") << false);
xlApp.Exec(Procedure("Quit"));
xlApp.Clear();
__________________
Los Estados Unidos parecen destinados por la Providencia para plagar la América de miserias a nombre de la libertad."
Simón Bolívar
(Carta al Coronel Inglés Patricio Cambell 05/08/1829).
Responder Con Cita