Visual Basic - Error al Modificar archivo Excel

Life is soft - evento anual de software empresarial
 
Vista:

Error al Modificar archivo Excel

Publicado por Cesar (80 intervenciones) el 10/06/2008 16:16:28
Tengo el siguiente código en donde modificado un archivo excel, pero de repente se producce un error al momento de ingresar datos por segunda vez ( ActiveSheet.Range("A1").Activate ) o bien se cae en la tercera o cuarta no se porque. Y por otra parte y ejecuto el archivo (Libro2) no se puede ejecutar tengo que ir al adminitrador de tareas y finalizarlo y de hay se puede abrir el arhivo ¿ Cual es Error?, espero haber sido claro

Set oExcelApp = New Excel.Application
Set oBook = oExcelApp.Workbooks.Open(App.Path & "Libro2.xls")
Set oWorksheet = oBook.ActiveSheet
Set oWorksheet = oBook.Worksheets("Hoja1")
ActiveSheet.Range("A1").Activate ''Aqui se se Cae
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Activate
Loop
ActiveCell.Offset(0, 0).Value = Banco.Text
ActiveCell.Offset(0, 1).Value = "plaza"
ActiveCell.Offset(0, 2).Value = Numero.Text
ActiveCell.Offset(0, 3).Value = Cuenta.Text
ActiveCell.Offset(0, 4).Value = ChequeAfecha.FechaRet.Value
ActiveCell.Offset(0, 5).Value = "Nombre.cliente"
ActiveCell.Offset(0, 6).Value = Rut.Text
ActiveCell.Offset(0, 7).Value = "PPPP"
ActiveCell.Offset(0, 8).Value = FechaDep.Value
ActiveCell.Offset(0, 9).Value = Format(Monto.Text, "0")
ActiveWorkbook.Save
oExcelApp.Quit
oExcelApp.Visible = True
Set oExcelApp = Nothing
Set oBook = Nothing
Set oWorksheet = Nothing
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de andres guerrero
Val: 3.117
Oro
Ha mantenido su posición en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

RE:Error al Modificar archivo Excel

Publicado por andres guerrero  (1798 intervenciones) el 10/06/2008 18:47:50
Saludos Cesasr

Prueba con el metodo SELect

ActiveSheet.Range("A1").Select

Ya que aqui solo lo situas para qeu inicie tu proceso.

SAludos desde Ecuadro
Andres.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Error al Modificar archivo Excel

Publicado por JuanC (68 intervenciones) el 10/06/2008 23:05:34
veamos...
Set oWorksheet = oBook.ActiveSheet 'Asignás la hoja activa
Set oWorksheet = oBook.Worksheets("Hoja1") 'Ahora asignás la hoja 1??
ActiveSheet.Range("A1").Activate ''Aqui se se Cae 'En lugar de ActiveSheet no deberías usar oWorksheet?? o para qué fue asignada...??

Saludos desde Baires, JuanC
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar