Visual Basic - Enviar a excel desde vb6.0 a un libro y hoja existente!

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

Enviar a excel desde vb6.0 a un libro y hoja existente!

Publicado por mat (32 intervenciones) el 18/10/2014 22:50:00
Chicos aca les dejo un codigo que me ayudo mucho y ami personalmente me dio lidia construirlo espero les sirva mi pekeño aporte

este codigo exporta datos de las cajas de texto de vb6.0 a celdas de excel


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Private Sub reporte()
On Error GoTo mal
Dim objArchivoXls As Object
Dim co1 As Integer
Dim intUltimo As Long
Const xlDown As Integer = -4121
If Len(Dir("c:\mi libro.xls")) > 0 Then
Set objArchivoXls = GetObject("c:\mi libro.xls") <- ruta del libro
objArchivoXls.Worksheets(Combo1.Text).Activate <-- nombre de la hoja
With objArchivoXls.ActiveSheet
.Parent.Windows("mi libro.xls").Visible = True
intUltimo = .Range("A1").End(xlDown).Row + 1
For co1 = intUltimo To intUltimo + 0
.Cells(co1, 1).Value = Format(CDate(Date), "mm/dd/yyyy")
.Cells(co1, 2).Value = Time
.Cells(co1, 3).Value = "Text2"
.Cells(co1, 4).Value = "Text3"
.Cells(co1, 5).Value = "Text4"
.Cells(co1, 6).Value = "Text9"
.Cells(co1, 7).Value = "Text6"
.Cells(co1, 8).Value = "Text7"
Next co1
End With
objArchivoXls.Save
objArchivoXls.Parent.Quit
Set objArchivoXls = Nothing
MsgBox "Proceso terminado"
Else
MsgBox "Archivo no existe"
End If
Exit Sub
mal:
MsgBox "Hoja de calculos no encontrada"
objArchivoXls.Parent.Quit
Set objArchivoXls = Nothing
End Sub
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