talytech
05-28-2008, 09:11 AM
I have a workbook that displays a form from a button (Riskform.Show). On that form is an approve button. When the user clicks that button I want an email sent and the workbook closed without it asking you to save. I thought my code was ok but it promts me to save. Can someone please assist me with this problem? Here is my code behind the Approve button on the userform. The userform is called "RiskForm"
Dim theName, theSub, theRecipient As String
If Worksheets("sheet1").CheckBox1.Value = True And Worksheets("sheet1").CheckBox2.Value = False Then
RiskForm.Hide
theName = "FTE - " & Worksheets("sheet1").Range("c21") & " " & Worksheets("sheet1").Range("f21") & " " & Worksheets("sheet1").Range("h21")
theSub = "SUBMITTAL: EXCEPTION REQUEST FORM FOR (" & theName & ")"
theRecipient = "corporate_security@fanniemae.com"
ActiveWorkbook.SendMail theRecipient, theSub
ActiveWorkbook.Close SaveChanges:=False
Application.Quit
ElseIf Worksheets("sheet1").CheckBox1.Value = False And Worksheets("sheet1").CheckBox2.Value = True Then
RiskForm.Hide
theName = "Contractor - " & Worksheets("sheet1").Range("c25") & " " & Worksheets("sheet1").Range("f25") & " " & Worksheets("sheet1").Range("h25")
'send the email
theSub = "SUBMITTAL: EXCEPTION REQUEST FORM FOR (" & theName & ")"
theRecipient = "corporate_security@talytech.com"
ActiveWorkbook.SendMail theRecipient, theSub
ActiveWorkbook.Close SaveChanges:=False
Application.Quit
End If
Dim theName, theSub, theRecipient As String
If Worksheets("sheet1").CheckBox1.Value = True And Worksheets("sheet1").CheckBox2.Value = False Then
RiskForm.Hide
theName = "FTE - " & Worksheets("sheet1").Range("c21") & " " & Worksheets("sheet1").Range("f21") & " " & Worksheets("sheet1").Range("h21")
theSub = "SUBMITTAL: EXCEPTION REQUEST FORM FOR (" & theName & ")"
theRecipient = "corporate_security@fanniemae.com"
ActiveWorkbook.SendMail theRecipient, theSub
ActiveWorkbook.Close SaveChanges:=False
Application.Quit
ElseIf Worksheets("sheet1").CheckBox1.Value = False And Worksheets("sheet1").CheckBox2.Value = True Then
RiskForm.Hide
theName = "Contractor - " & Worksheets("sheet1").Range("c25") & " " & Worksheets("sheet1").Range("f25") & " " & Worksheets("sheet1").Range("h25")
'send the email
theSub = "SUBMITTAL: EXCEPTION REQUEST FORM FOR (" & theName & ")"
theRecipient = "corporate_security@talytech.com"
ActiveWorkbook.SendMail theRecipient, theSub
ActiveWorkbook.Close SaveChanges:=False
Application.Quit
End If