' Module: MainModule ' Description: Main entry points for the application Public Sub ShowMenu() ' Display the main menu form Menu.Show End Sub Public Sub ProcessLogs() ' Update logs and refresh data RunPythonLogProcessor RefreshLogData End Sub Public Sub GenerateInvoice() ' Generate invoice by showing date selection form ShowDateSelectionForm End Sub Public Sub ExportCommessaSheet() ' Export Comesse sheet to Excel ExportComessaToExcel End Sub ' Helper function to display date selection form Private Sub ShowDateSelectionForm() Dim wsHoras As Worksheet Dim fechaDesde As Date, fechaHasta As Date Dim rangoSeleccionado As Range ' Set reference to Horas sheet Set wsHoras = ThisWorkbook.Sheets(SHEET_HORAS) ' Check if there's a selected range in Horas sheet and column E If Not Application.Selection Is Nothing Then Set rangoSeleccionado = Application.Selection If rangoSeleccionado.Worksheet.Name = SHEET_HORAS And _ rangoSeleccionado.EntireColumn.Address = wsHoras.Columns("E").Address Then ' Use dates from selected range fechaDesde = rangoSeleccionado.Cells(1, 1).Value2 fechaHasta = rangoSeleccionado.Cells(rangoSeleccionado.Rows.Count, 1).Value2 End If End If ' If no appropriate selection, use default date calculation If fechaDesde = 0 Or fechaHasta = 0 Then fechaHasta = GetDefaultEndDate() fechaDesde = GetDefaultStartDate(fechaHasta) End If ' Set default values in the form ConsultarFechas.t_hasta.Value = Format(fechaHasta, "dd/mm/yyyy") ConsultarFechas.t_desde.Value = Format(fechaDesde, "dd/mm/yyyy") ' Set invoice number ConsultarFechas.frm_factnro.Value = ThisWorkbook.Sheets(SHEET_NOTA).Cells(6, 3).Value ' Show form ConsultarFechas.Show End Sub Public Sub RunDiagnostic() ' Run a diagnostic test Debug.Print "System Diagnostics:" Debug.Print "-------------------" Debug.Print "Python Path: " & PYTHON_EXE_PATH Debug.Print "Script Path: " & SCRIPT_PATH Debug.Print "Log Path: " & LOG_FILE_PATH Debug.Print "Excel Log Path: " & LOG_EXCEL_PATH Dim testResult As Double testResult = SumarPorMes(Sheets(SHEET_HORAS).Range("E3:E367"), Month(Date), Sheets(SHEET_HORAS).Range("O3:O367")) Debug.Print "Test sum for current month: " & testResult End Sub