hola, bueno en si lo que deseo hacer es editar un documento de excel ya creado, ya que buscando en Internet solo eh encontrado tutoriales de como crearlos y darles formato, mi objetivo es generar un reporte diariamente con ciertos datos, el problema
que los datos se van generando en determinadas horas del día, y en caso de que se cierre la aplicación y se desee utilizar posteriormente el documento ya se habrá generado y le corresponde el mismo día, lo único que
busco es como seleccionarlo en una variable o no se si tengan una idea mejor , lo que llevo es esto
Public Sub reporte()
Dim reporte_generado As Boolean
nombrar_reporte()
reporte_generado = System.IO.Directory.Exists(My.Settings.Sett_Direccion_Carpeta_Reportes & "\" & Date.Now.Year & "\" & mes_del_reporte & "\" & nombre_reporte & ".xlsx
")
If reporte_generado = True Then
agregar_a_repote()
Else
generar_reporte_clase()
End If
End Sub
Sub generar_reporte_clase()
Try
tipo_de_reporte = True
Excel_Documeto = New Excel.Application
Excel_Libro = Excel_Documeto.Workbooks.Add(misValue)
Excel_Hoja = Excel_Libro.Sheets(1)
'Encabezado
Excel_Hoja.Shapes.AddPicture(My.Settings.Sett_DireccionImagenReporte, _
Microsoft.Office.Core.MsoTriState.msoFalse, _
Microsoft.Office.Core.MsoTriState.msoCTrue, 3, 5, 160, 40) ' A1-C4
With Excel_Hoja
.Name = "Clase de " & fecha_r
.Visible = XlSheetVisibility.xlSheetVisible
.Activate()
'Titulo
.Range("D2").Value = "Reporte de Clase"
.Range("D2").Font.ColorIndex = 3
'Guardar y Cerrar
guardar_reporte()
Excel_Libro.Close()
Excel_Documeto.Quit()
End With
Catch ex As Exception
MsgBox("Error " & ex.Message, MsgBoxStyle.Information)
End Try
End Sub
Sub agregar_a_repote()
Try
tipo_de_reporte = True
Dim Excel_DocumetoE As Object
Excel_DocumetoE = (My.Settings.Sett_Direccion_Carpeta_Reportes & "\" & Date.Now.Year & "\" & mes_del_reporte & "\" & nombre_reporte & ".xlsx ")
Excel_Libro = Excel_DocumetoE.Workbooks(1)
Excel_Hoja = Excel_DocumetoE.Worksheets.Add(After:=Excel_Libro.Worksheets(Excel_Libro.Worksheets.Count))
'Encabezado
Excel_Hoja.Shapes.AddPicture(My.Settings.Sett_DireccionImagenReporte, _
Microsoft.Office.Core.MsoTriState.msoFalse, _
Microsoft.Office.Core.MsoTriState.msoCTrue, 3, 5, 160, 40) ' A1-C4
With Excel_Hoja
.Name = "Clase N°"
.Visible = XlSheetVisibility.xlSheetVisible
.Activate()
'Titulo
.Range("D2").Value = "Reporte de Clase"
'Guardar y Cerrar
guardar_reporte()
Excel_Libro.Close()
Excel_Documeto.Quit()
End With
Catch ex As Exception
MsgBox("Error " & ex.Message, MsgBoxStyle.Information)
End Try
End Sub