VBA Addition for Blank Text Box

FisherKat

New Member
Joined
Oct 16, 2018
Messages
14
I have this VBA to auto generate an email upon completion of a form and a submit button, however, due to consistent issues with their information I need to add the ability to not create the email and attach the form if the text boxes are not filled out. Does anyone know of a means to do that by adding to this VBA macro?

Thank you!!

Sub SendWorkBook()


Dim mystr As String
Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)


Call YesNoMessageBox


mystr = Sheets("Cover Sheet").Range("AL14").Value 'change sheet name
On Error Resume Next
With OutlookMail
.To = ""
.CC = ""
.BCC = ""
.Subject = mystr
.Body = "Hello," & vbNewLine & vbNewLine & "This DAF is being submitted for your processing." & vbNewLine & vbNewLine & "Thank You!"
.Attachments.Add Application.ActiveWorkbook.FullName
.Send
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing


End Sub


Sub YesNoMessageBox()

Dim Answer As String
Dim MyNote As String

MyNote = "Have you saved this document?"

Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "Thank You!")

If Answer = vbNo Then
MsgBox "This document will not be sent at this time. Please save your document and then click SUBMIT once more. Thank you."

End

Else
MsgBox "Your Document will now be forwarded to Document Control. Thank you!"

MyNote = "Are you sure you wish to send your submittal at this time?"

Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "Thank You!")


End If

End Sub

Thanks everyone for taking the time to look at this and help!!
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,223,703
Messages
6,173,941
Members
452,539
Latest member
delvey

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top