### RESPUESTA A LA PREGUNTA 36227 - VB.NET ### ### Elena Gonzalez ea_eo[at]yahoo.es ### ### http://www.lawebdelprogramador.com ### Sub exporta() On Local Error GoTo salir Dim varible_temporal As Double Dim Fila As Integer 'fila de excel Dim n_dia As Integer 'la fecha la exporta mal simpre si lo haces asi resulta bien Dim n_mes As Integer Dim n_ano As Integer Dim objexcel As Excel.Application Dim VCLM As Integer 'Varible Cuenta Linea Malla Set objexcel = CreateObject("Excel.Application") objexcel.SheetsInNewWorkbook = 1 objexcel.Workbooks.Add Fila = 5 With objexcel.ActiveSheet .Name = "Comportamiento" .Cells(1, 1) = "titulo " .Cells(2, 2) = "titulo de la pantalla" .Cells(4, 1) = "titulo campo1" .Cells(4, 2) = "titulo campo1" End With For VCLM = 1 To Malla_Comportam.Rows - 1 Malla_Comportam.Row = ln Malla_Comportam.Col = 1 varible_temporal = Val(Malla_Comportam.Text) With objexcel.ActiveSheet .Cells(Fila, 1) = x_Matri_aux n_dia = Format(x_fven_aux, "dd") n_mes = Format(x_fven_aux, "mm") n_ano = Format(x_fven_aux, "yyyy") .Cells(Fila, 2) = n_dia .Cells(Fila, 3) = n_mes .Cells(Fila, 4) = n_ano .Cells(Fila, 5) = "=Date(O" & Fila & "," & "N" & Fila & "," & "M" & Fila & ")" pasa_linea = pasa_linea + 1 End With Fila = Fila + 1 Next ln archivo = App.Path & "\Exportaciones\nombre.xls" objexcel.ActiveWorkbook.SaveCopyAs archivo objexcel.ActiveWorkbook.Saved = True objexcel.Workbooks.Close Set objexcel = Nothing MsgBox archivo, , True Exit Sub salir: MSGSYSTEM "Error debido a :" & Err.Description & vbCrLf & _ vbCrLf & Me.Name & _ "\Sub exporta", , True Err.Number = 0 End Sub 3. el otro modo si son pco datos es mas recomendables asi: Sub exporta2() Set objexcel = CreateObject("Excel.application") objexcel.Visible = True objexcel.Workbooks.Add '____________________________ENCABEZADO With objexcel.ActiveSheet .Cells(1, 1) = " titulo" .Cells(5, 1) = "Fecha" .Cells(5, 2) = "Matrícula" End With Fila = 5 For IRFMI = 1 To Malla_Imprime.Rows - 1 Fila = Fila + 1 With Malla_Imprime .Row = IRFMI .Col = ImpAut_Fecha0: x_Fecha = .Text .Col = ImpAut_Matric1: x_Matri = Val(.Text) End With With objexcel.ActiveSheet .Cells(Fila, 1) = x_Fecha: .Cells(Fila, 1).HorizontalAlignment = 3 .Cells(Fila, 2) = x_Matri: .Cells(Fila, 2).HorizontalAlignment = 3 End With With objexcel.ActiveSheet .Range(.Cells(1, 1), .Cells(5, 6)).Font.Size = 10 .Range(.Cells(1, 1), .Cells(5, 6)).Font.Name = "Arial" .Range(.Cells(1, 1), .Cells(5, 6)).Font.Bold = True End With conta = conta + 1 Next IRFMI Fila = Fila + 2 With objexcel.ActiveSheet .Cells(Fila, 1) = " Total Alumno " & conta .Range(.Cells(Fila, 1), .Cells(Fila, 6)).Font.Size = 10 .Range(.Cells(Fila, 1), .Cells(Fila, 6)).Font.Name = "Arial" .Range(.Cells(Fila, 1), .Cells(Fila, 6)).Font.Bold = True End With End Sub