Setting the reference to the [schedule next] cell and reading the value of the vba_out "next call on " _ [schedule interval]. & Format(schedule_next.Value, Calling the main job subroutine. hh:mm:ss") Application.OnTime schedule_next.Value, After the job subroutine execution is "Periodic" complete setting the new value of [schedule next] cell. Telling the excel shchart application to run this subroutine at datalock the time stored in [schedule next] cell. Switching now to the chart sheet. End Sub Protecting the worksheets. This function generates the PNG image of the chart, randomly selects one of Function Chart_Email() the SMTP accounts available for transmission and calls the SMTP Dim chart_path As String transmission function in order to email Dim chart_name As String the chart image. This function return Dim filename As String Dim smtp_account As range true if the transmission of email is successful. ThisWorkbook.Activate chart_path = Computing the folder name the Application.ActiveWorkbook.Path & "\" _ charts must be stored. & Application.ThisWorkbook.Name _ & "_Charts" If the folder does not exists yet, create it. If Len(Dir(chart_path, vbDirectory)) = 0 Then MkDir chart_path End If chart_name = _ Format( _ Computing the current PNG file WorksheetFunction.Min(range("cdr_time")) _ name. The filename is formed by the + range("time_zone").Value / 24, _ first CDR calls date and time, the last "yymmdd'hhmmss") & "_" & _ CDR calls date and time, and the Format( _ current time. The CDR times are converted into the local time zone. WorksheetFunction.Max(range("cdr_time")) _ + range("time_zone").Value / 24, Full path filename of the chart is _ obtained. "yymmdd'hhmmss") & "_" & _ Format( _ Now, _ "yymmdd'hhmmss") & ".png"
vba_out "next call on " _ & Format(schedule_next.Value, hh:mm:ss") Application.OnTime schedule_next.Value, "Periodic" shchart datalock End Sub Setting the reference to the [schedule next] cell and reading the value of the [schedule interval]. Calling the main job subroutine. After the job subroutine execution is complete setting the new value of [schedule next] cell. Telling the excel application to run this subroutine at the time stored in [schedule next] cell. Switching now to the chart sheet. Protecting the worksheets. Function Chart_Email() Dim chart_path As String Dim chart_name As String Dim filename As String Dim smtp_account As range This function generates the PNG image of the chart, randomly selects one of the SMTP accounts available for transmission and calls the SMTP transmission function in order to email the chart image. This function return true if the transmission of email is successful. ThisWorkbook.Activate chart_path = Application.ActiveWorkbook.Path & "\" _ & Application.ThisWorkbook.Name _ & "_Charts" If Len(Dir(chart_path, vbDirectory)) = 0 Then MkDir chart_path End If Computing the folder name the charts must be stored. If the folder does not exists yet, create it. chart_name = _ Format( _ WorksheetFunction.Min(range("cdr_time")) _ + range("time_zone").Value / 24, _ "yymmdd'hhmmss") & "_" & _ Format( _ WorksheetFunction.Max(range("cdr_time")) _ + range("time_zone").Value / 24, _ "yymmdd'hhmmss") & "_" & _ Format( _ Now, _ "yymmdd'hhmmss") & ".png" Computing the current PNG file name. The filename is formed by the first CDR calls date and time, the last CDR calls date and time, and the current time. The CDR times are converted into the local time zone. Full path filename of the chart is obtained.