Ver Mensaje Individual
  #2 (permalink)  
Antiguo 24/04/2008, 17:03
DragonForce
 
Fecha de Ingreso: abril-2008
Mensajes: 2
Antigüedad: 17 años
Puntos: 0
Re: exportar list a excel

Debes habiliar la referencia Microsoft Excel (version) Object Library

Supongamos que tienes un listbox con 8 filas o las que sean pega esto en un boton y listo!:

Dim aux

Set XLAPP = Nothing

'se crea objeto de excel
Set XLAPP = CreateObject("excel.sheet.8")

'se abre el archivo
Set xlBook = XLAPP.Application.Workbooks.Open(App.Path & "\Plantilla2.xls")

'XLAPP.Application.Visible = False ' para no mostra
XLAPP.Application.Visible = True ' para mostrar

Set RESUMEN = xlBook.ActiveSheet

renglones = List1.ListCount
Renglon = 4 'linea en donde comenzaras a pegar datos

For linea = 0 To renglones - 1
TextoX = List1.List(linea)
RESUMEN.Range("B" & Renglon).Value = TextoX
Renglon = Renglon + 1
Next linea


'RESUMEN.PrintOut 'Para imprimir
Set RESUMEN = Nothing
Set XLAPP = Nothing