Email Confirmation from PowerPoint.

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
 
D

David M. Marcovitz

Don't you want something more like:

If Me.TxtCompName.Text = "" Then

to see if the text in the text box is blank (that's two double quotes
with nothing between them).

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
G

Guest

Thank you for your reply. I add this in:

If 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

and then the creation of the Outlook object and after the saving and quiting
of the powerpoint, the end if.

Once I put this in, none of the code does anything. I hit the command
button and nothing happens. This is a good suggestion.
 
D

David M. Marcovitz

Thank you for your reply. I add this in:

If 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

and then the creation of the Outlook object and after the saving and
quiting of the powerpoint, the end if.

Once I put this in, none of the code does anything. I hit the command
button and nothing happens. This is a good suggestion.

You're dealing with control text box, right? I think you want the .Text,
not the .Value of the text box. That will tell you if nothing is typed in
the text box.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
D

David M. Marcovitz

You're dealing with control text box, right? I think you want the
.Text, not the .Value of the text box. That will tell you if nothing
is typed in the text box.
--David


Actually, both .Text and .Value seem to work, so it seems to me that
Me.txtCompName is not the text box that you think it is.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
G

Guest

I like these suggestions. I did check the text box name and it fits. It is
really frustrating, because when I create it, it works. If I change any of
the code to add this in, the code stops working. Even if I take this segment
back out again, the email no longer sends.
 
D

David M. Marcovitz

A more careful look at your code reveals that your Dim statements are in
the middle of your Sub. Try moving them back up to the top (right after the
Private Sub) statement.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
G

Guest

Thank you for your response. I apologize for this delay in responding. I
tried moving that up. I even tried removing all commenting. The thing I
don't get is, if I make a ppt from scratch, and put the code on a command
button, it works. If I edit the code at all, even if I put it back exactly
as it was (take out 1 letter and put it back) the code no longer works. When
I say it doesn't work, I mean, go to presentation mode, click the button
(named CommandButton1) and nothing will happen. Even with this code behind
it:

Private Sub CommandButton1_Click()
Dim objOutlook As Object 'Outlook.Application
Dim objOutlookMsg As Object 'Outlook.MailItem
Dim objOutlookRecip As Object 'Outlook.Recipient

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(0)

With objOutlookMsg
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
objOutlookRecip.Type = 1
.Subject = Me.TextBox1.Value & " has completed the Unlawful Harrassment
Orientation"
.Save
.Send

End With
End Sub
------------------

Are you experienced in dealing with coding in powerpoint? I could really
use some help understanding why mircosoft made this so difficult. I create
access applications all the time, with no problem. What works there, just
doesnt work here. grrr. lol

Thanks for your continued help.
 
D

David M. Marcovitz

I wonder if your presentation somehow got corrupted. However, you said
that you tried starting from scratch and had the same problem. If you
have coded in Access, then you know that VBA is not very talkative so
stupid little things can cause the whole thing to stop working, but
taking out a letter and putting it back shouldn't have that effect. The
only suggestions I have left are to assume that either your presentation
is corrupted or PowerPoint itself is corrupted. Have you tried Help >
Detect and Repair? Have your tried compiling your code after you make a
change? I'm grasping at straws now. I wonder if someone else has a better
idea.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
G

Guest

All of your suggestions make sense. The odd thing is that I have copied the
presentation. Remade a new one, and the same thing will still happen. I
have also been doing this on more than one computer. Here is the only thing.
one is 2003, the other is xp. Anyway. I am at a loss. I just created a
new slide and deleted the old one. Looking at my code above, I don't see why
yhtat wouldnt work. It still doesn't.

If I can just get that to work, it would be really nice!

Thanks,
 
G

Guest

Ahhh!!! I figured it out! My macro security somehow got set to high. lol.
I changed it to low, and now it works. omg.

I tested the textbox1.value = "" instead of null and it worked!

Thank you!
 
D

David M. Marcovitz

It's always the stupid little things with VBA. I'm glad you figured it out.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top