Hi Mike,
hereby my code, what must go in between?
Private Sub CommandButton1_Click()
End Sub
Sub Checkofcells(Cancel As Boolean)
'check cells before sending
For Each cell In Range("B5,B11,H6,H8,H9,C16,D42")
If cell.Value = "" Then
MsgBox "Please complete red field before sending.", vbCritical, "Missing Info"
cell.Select
Cancel = True
Exit Sub
End If
Next
End Sub
Sub SendWorkBook()
'Update 20171227
Dim xFile As String
Dim xFormat As Long
Dim Wb As Workbook
Dim Wb2 As Workbook
Dim FilePath As String
Dim FileName As String
Dim rng As Range
Dim cel As Range
Dim OutLookApp As Object
Dim OutlookMail As Object
On Error Resume Next
Application.ScreenUpdating = False
Set Wb = Application.ActiveWorkbook
ActiveBook.Copy
Set Wb2 = Application.ActiveWorkbook
Select Case Wb.FileFormat
Case xlOpenXMLWorkbook:
xFile = ".xlsx"
xFormat = xlOpenXMLWorkbook
Case xlOpenXMLWorkbookMacroEnabled:
If Wb2.HasVBProject Then
xFile = ".xlsm"
xFormat = xlOpenXMLWorkbookMacroEnabled
Else
xFile = ".xlsx"
xFormat = xlOpenXMLWorkbook
End If
Case Excel8:
xFile = ".xls"
xFormat = Excel8
Case xlExcel12:
xFile = ".xlsb"
xFormat = xlExcel12
End Select
FilePath = Environ$("temp") & ""
FileName = Wb.Name & Format(Now, "dd-mmm-yy h-mm-ss")
Set OutLookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutLookApp.CreateItem(0)
Wb2.SaveAs FilePath & FileName & xFile, FileFormat:=xFormat
With OutlookMail
.To = "
Btest@atest.com"
.CC = ""
.BCC = ""
.Subject = "from"
.Body = ""
.Attachments.Add Wb2.FullName
.Send
'Display
End With
Wb2.Close
Kill FilePath & FileName & xFile
Set OutlookMail = Nothing
Set OutLookApp = Nothing
Application.ScreenUpdating = True
End Sub