T
Todd
I am trying to add the following code to a command button
so it will run when the button is pressed. I created the
command button then inserted the code under the "Private
Sub CommanButton1_click () phrase. It returns a compile
error message of "Expected End Sub" when it is run. Is
the wording incorrect on this or is there another
problem? Thanks for the help. The code is below:
Private Sub CommandButton1_Click()
Sub Mail_workbook_Outlook()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
End Sub
so it will run when the button is pressed. I created the
command button then inserted the code under the "Private
Sub CommanButton1_click () phrase. It returns a compile
error message of "Expected End Sub" when it is run. Is
the wording incorrect on this or is there another
problem? Thanks for the help. The code is below:
Private Sub CommandButton1_Click()
Sub Mail_workbook_Outlook()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add ActiveWorkbook.FullName
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
End Sub