A
andrewbt
Hello everyone.
I am currently using the code below when assigned to a form button to e-mail
off a workbook. Over the course of using my system different worksheets are
added to the workbook. Does anyone know of any way in which i can change the
e-mail address if the Wb contains a certain worksheet? e.g If workbook
contains "Wksht1" or "Wksht2" then send to (e-mail address removed) OR/AND if
Workbook contains "wksht 3" or "Wksht 4" then send to (e-mail address removed). If
there is any way that can be added to the code below you will be a lifesaver.
VB is not my first language and it's getting me in strife! Thanks in
advance, Andrew bt
Dim wb As Workbook
Set wb = ActiveWorkbook
If Val(Application.Version) >= 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will be no
VBA code in the file you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro
again.", vbInformation
Exit Sub
End If
End If
On Error Resume Next
wb.SendMail "(e-mail address removed)", _
"Test e-mail"
On Error GoTo 0
End Sub
I am currently using the code below when assigned to a form button to e-mail
off a workbook. Over the course of using my system different worksheets are
added to the workbook. Does anyone know of any way in which i can change the
e-mail address if the Wb contains a certain worksheet? e.g If workbook
contains "Wksht1" or "Wksht2" then send to (e-mail address removed) OR/AND if
Workbook contains "wksht 3" or "Wksht 4" then send to (e-mail address removed). If
there is any way that can be added to the code below you will be a lifesaver.
VB is not my first language and it's getting me in strife! Thanks in
advance, Andrew bt
Dim wb As Workbook
Set wb = ActiveWorkbook
If Val(Application.Version) >= 12 Then
If wb.FileFormat = 51 And wb.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file, there will be no
VBA code in the file you send." & vbNewLine & _
"Save the file first as xlsm and then try the macro
again.", vbInformation
Exit Sub
End If
End If
On Error Resume Next
wb.SendMail "(e-mail address removed)", _
"Test e-mail"
On Error GoTo 0
End Sub