filename = chart_path & "\" & chart_name vba_out "exporting to " & chart_name Exporting the chart image into the If Then PNG file. In our case we export the Worksheets(1).ChartObjects(1).Activate chart object represented by the chart ActiveChart.Export filename sheet instead of exporting the chart Else located in the data worksheet. Charts(1).Export filename End If Set the SMTP account range to one of the three user defined SMTP accounts for transmission of email. We use three accounts in our example, a google.com account, a switzernet.com account, and a yahoo.com account. In Select Case Int(Rnd * 3) + 1 case of a failure of transmission there Case 1 is a greater chance of a successful Set smtp_account = retransmission with more than one account. Case 2 Set smtp_account = Note: in the new version of this script (refer to the excel file available for Case 3 downloading), the number of accounts Set smtp_account = range("smtp_account3") is not fixed. Instead of using multiple End Select named ranges we use a single range with multiple areas. User can define this single range with any given number of areas. Each area must contain seven rows with credentials of the SMTP account. vba_out "emailing..." If SMTP( _ Parsing the SMTP account selection filename, _ and the filename to the email smtp_account) Then transmission function described vba_out "email sent" below. If the email transmission is Chart_Email = True unsuccessful we quit the function with Else the false return value. This permits the vba_err "failed to email" Chart_Email = False main job subroutine to attempt End If another retransmission of the email. End Function This function receives the filename Function SMTP(ByVal filename As String, ByVal smtp_account) As Boolean with the SMTP account information area as arguments and returns true if Dim iMsg As Object it succeeds to email the file.
filename = chart_path & "\" & chart_name vba_out "exporting to " & chart_name If Then Worksheets(1).ChartObjects(1).Activate ActiveChart.Export filename Else Charts(1).Export filename End If Exporting the chart image into the PNG file. In our case we export the chart object represented by the chart sheet instead of exporting the chart located in the data worksheet. Select Case Int(Rnd * 3) + 1 Case 1 Set smtp_account = Case 2 Set smtp_account = Case 3 Set smtp_account = range("smtp_account3") End Select Set the SMTP account range to one of the three user defined SMTP accounts for transmission of email. We use three accounts in our example, a google.com account, a switzernet.com account, and a yahoo.com account. In case of a failure of transmission there is a greater chance of a successful retransmission with more than one account. Note: in the new version of this script (refer to the excel file available for downloading), the number of accounts is not fixed. Instead of using multiple named ranges we use a single range with multiple areas. User can define this single range with any given number of areas. Each area must contain seven rows with credentials of the SMTP account. vba_out "emailing..." If SMTP( _ filename, _ smtp_account) Then vba_out "email sent" Chart_Email = True Else vba_err "failed to email" Chart_Email = False End If End Function Parsing the SMTP account selection and the filename to the email transmission function described below. If the email transmission is unsuccessful we quit the function with the false return value. This permits the main job subroutine to attempt another retransmission of the email. Function SMTP(ByVal filename As String, ByVal smtp_account) As Boolean Dim iMsg As Object This function receives the filename with the SMTP account information area as arguments and returns true if it succeeds to email the file.
index11.docx