There are a number of techniques for sending an Excel Workbook to someone via email. In this post I’ll show how to send the file via email using a Button and some basic VBA script. This allows the user to enter information into the sheet and click a button to send it to a recipient.
Here is a function called EmailFile. It sends the whole Worksheet to the recipient whose address is defined by the “strRecipients” variable. You will need to update this variable and insert the email address you want to send to.
Sub EmailFile() strSubject = "Feedback Form" strRecipients = "firstname.surname@example.com" ActiveWorkbook.SendMail Recipients:=strRecipients, _ Subject:=strSubject End Sub
Here is slightly more advanced version of the function. It uses an array to define a list of recipients so you can send to multiple people.
Sub EmailFile() Dim strSubject As String Dim strRecipients As Variant strSubject = "Feedback Form" strRecipients = Array("a.b@example.com", "x.y@example.com") ActiveWorkbook.SendMail Recipients:=strRecipients, _ Subject:=strSubject End Sub
Hopefully you’ll find this technique for sending excel workbooks via a button useful.