G
Guest
I am working on a presentation, where I need to have the viewer of the
presentation send confirmation that they have completed it. We know that
this is not a perfect process (holes - technically a person could jump to
this. we are assuming an honor system here).
I made code which sends an email and makes the subject include a value from
a text box, which is on the slide. The text box is where the user enters
their name. The code acts on a command button. It grabs the text box value,
composes the email, sends it, clears the text box and closes the
presentation. I want it to prompt with a message and not send the email, if
the user has not filled something into the text box. I will include the
code. The quick if then else at the beginning is ignored. Any thoughts?
Private Sub CommandButton1_Click()
If IsNull(Me.TxtCompName.Value) Then
MsgBox "You Must Fill Out Your Name to Confirm Completion of this
Presentation", vbOKOnly, "Please Fill in your Full Name"
Else
Dim objOutlook As Object 'Outlook.Application
Dim objOutlookMsg As Object 'Outlook.MailItem
Dim objOutlookRecip As Object 'Outlook.Recipient
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(0)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
objOutlookRecip.Type = 1
' Set the Subject and Body of the message; save and send message
.Subject = Me.TxtCompName.Value & " Has Completed the Harrassment
Presentation"
' this could be from a variable if you have one
' .Body = Me.txtExample & " has successfully completed the Sexual
Harrassment Presentation on " & Date
' this could be from a variable if you have one
.Save
' objMailItem.Save
'Set objSafeMail = CreateObject("Redemption.SafeMailItem")
'objSafeMail.Item = objMailItem
'objSafeMail.Send
.Send
End With
Set objOutlook = Nothing
Me.TxtCompName.Value = ""
With Application
For Each w In .Presentations
w.Save
Next w
.Quit
End With
End If
End Sub
Thank you
presentation send confirmation that they have completed it. We know that
this is not a perfect process (holes - technically a person could jump to
this. we are assuming an honor system here).
I made code which sends an email and makes the subject include a value from
a text box, which is on the slide. The text box is where the user enters
their name. The code acts on a command button. It grabs the text box value,
composes the email, sends it, clears the text box and closes the
presentation. I want it to prompt with a message and not send the email, if
the user has not filled something into the text box. I will include the
code. The quick if then else at the beginning is ignored. Any thoughts?
Private Sub CommandButton1_Click()
If IsNull(Me.TxtCompName.Value) Then
MsgBox "You Must Fill Out Your Name to Confirm Completion of this
Presentation", vbOKOnly, "Please Fill in your Full Name"
Else
Dim objOutlook As Object 'Outlook.Application
Dim objOutlookMsg As Object 'Outlook.MailItem
Dim objOutlookRecip As Object 'Outlook.Recipient
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(0)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
objOutlookRecip.Type = 1
' Set the Subject and Body of the message; save and send message
.Subject = Me.TxtCompName.Value & " Has Completed the Harrassment
Presentation"
' this could be from a variable if you have one
' .Body = Me.txtExample & " has successfully completed the Sexual
Harrassment Presentation on " & Date
' this could be from a variable if you have one
.Save
' objMailItem.Save
'Set objSafeMail = CreateObject("Redemption.SafeMailItem")
'objSafeMail.Item = objMailItem
'objSafeMail.Send
.Send
End With
Set objOutlook = Nothing
Me.TxtCompName.Value = ""
With Application
For Each w In .Presentations
w.Save
Next w
.Quit
End With
End If
End Sub
Thank you