Removing info from text box once it's saved to a file

G

Guest

Hi everyone,

I'm trying to set up a presentation slide on my touch-screen monitor where
people can type their contact info in the text-box by using the on-screen
keyboard. The problem I'm stuck with is that once the user hits the button
SAVE and the info is sent to my file, this info still stays in the text-box.
Is it possible to make it dissapear once it's saved, so next users can also
type their info?

Currently I use this routine to send info from the text-box to a file:

Sub SaveMe()
' ALL ON ONE LINE:
Call WriteStringToFile("C:\Temp\Infofile.txt",
ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text)
' Substitute the path/file.ext you want to use above
End Sub

Sub WriteStringToFile(pFileName As String, pString As String)
Dim intFileNum As Integer
intFileNum = FreeFile
Open pFileName For Output As intFileNum
Print #intFileNum, pString
Close intFileNum
End Sub


What and where should I insert in this code to make info dissapear once it's
saved?

Thank you and would really appreciate your suggestion,
Serge
 
S

Steve Rindsberg

Already replied to this earlier but here goes again:
I'm trying to set up a presentation slide on my touch-screen monitor where
people can type their contact info in the text-box by using the on-screen
keyboard. The problem I'm stuck with is that once the user hits the button
SAVE and the info is sent to my file, this info still stays in the text-box.
Is it possible to make it dissapear once it's saved, so next users can also
type their info?

Currently I use this routine to send info from the text-box to a file:
Sub SaveMe()
' ALL ON ONE LINE:
Call WriteStringToFile("C:\Temp\Infofile.txt",
ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text)

' add this after writing the text to file:
ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text = ""

End Sub
 
G

Guest

Hi Steve,

Thank you - it works now.. but how to make the info typed and saved by
different users accumulate in my file - right now the info saved by the last
user substitutes the info that was saved there before.

Thank you,

Serge
 
G

Guest

Thank you John,

It works fine now. Is it possible to put a pop-up "Thank You" note appearing
for 1-2 seconds when users clicks SAVE, to let them know that their info is
accepted?

Best,

Serge
 
S

Steve Rindsberg

Thank you John,

It works fine now. Is it possible to put a pop-up "Thank You" note appearing
for 1-2 seconds when users clicks SAVE, to let them know that their info is
accepted?

Settle for a message that they can read and click OK to dismiss?

Add this:

MsgBox "Thanks a bunch. Loved your answers. Click OK to make me go away"
 
G

Guest

Thank you very much guys - all works fine! You are the best!

Steve,
I'm sorry if it's too much to ask for, but is it possible instead of this
standard pop-up text-box window, to have my own custom shape appear with
words "THANK YOU.., etc." and button OK to dismiss it?

Thank you,

Serge
 
D

David M. Marcovitz

MsgBox is the easiest, but if you want your own shape, you could use the
AddShape method
(ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddShape) or you
could create a shape in advance and hide it. When the time is right, have
the shape become visible

ActivePresentation.Slides(5).Shapes("SecretButton").Visible = msoTrue

This makes a shape named "SecretButton" on slide 5 become visible. The
code linked to that shape can be to make it invisible again (change True
to False above). However, once you're going this route, you might as well
go back to your original specification and have the shape become visible,
wait 2 seconds and have the shape disappear. Example 8.4 on my site
(http://www.PowerfulPowerPoint.com/) shows how to do the delay.

--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

Hi David,
I created a shape on another slide #2, called it SecretButton, inserted in
my code the line ActivePresentation.Slides(2).Shapes("SecretButton").Visible
= msoTrue, and it doesn't work - the shape does not appear when the SAVE
buttone is clicked.

What do I do wrong?

Thank you,
Serge
 
D

David M. Marcovitz

When you say that you called it SecretButton, how did you give it that
name. As far as I know, the name has to be given with code (see Example
8.7 on my site). Now, you say that you inserted the shape and used the
code, but if you didn't use code to hide the shape, it should already be
visible. If it is not, you either didn't insert it, you put it off of the
slide, or you set an entrance animation. The .Visible code doesn't
trigger an entrance animation or move the shape, it just makes it show up
in whatever place and whatever state it is in.
--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

Hi David,
I'm a bit confused. What do you mean by "hiding a shape" - to create it on a
new slide (let's say Slide 2)? And then create a new module with code you
gave me(ActivePresentation.Slides(2).Shapes("SecretButton").Visible =
msoTrue) and assign it to this shape?
If yes, it doesn't work.
How do I co-relate it with the click on shape SAVE on my 1st Slide?

Thank you,

Serge
 
D

David M. Marcovitz

If you have a shape named SecretButton, and that shape resides on Slide
2, then you can run a procedure, such as:

Sub HideSecretButton()
ActivePresentation.Slides(2).Shapes("SecretButton").Visible = msoTrue
End Sub

You could assign this procedure to some other button (possibly a button
on slide 1, and the shape on Slide 2 would hide. By the way, don't do
this in a new module. Multiple modules will just complicate things.

Look at Example 6.6 on my site for a simple example of hiding and showing
shapes.

--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

Hi David,
I have a shape SAVE on the first slide (the one one that send typed test to
my file). So, I've added your procedure to the code assigned to this shape.
Now it look like this:

Sub SaveMe()
' ALL ON ONE LINE:
Call WriteStringToFile("C:\Temp\Infofile.txt",
ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text)
' add this after writing the text to file:
ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text = ""
' Substitute the path/file.ext you want to use above
MsgBox "Thank you"

End Sub

Sub WriteStringToFile(pFileName As String, pString As String)

Dim intFileNum As Integer
intFileNum = FreeFile
Open pFileName For Append As intFileNum
Print #intFileNum, pString
Close intFileNum
End Sub
Sub HideSecretButton()
ActivePresentation.Slides(2).Shapes("SecretButton").Visible = msoTrue
End Sub

And I assigned this procedure to the shape SecretButton on a second file.

When I type text and click SAVE - nothing happents, the shape SecretButton
does not appear.

I also tried to add same line with Falce - doesn't work.

Serge
 
D

David M. Marcovitz

I guess I'm confused as to what you are doing. You have a procedure named
"HideSecretButton" that has code to show the shape secret button. And,
you said that you assigned the procedure to the SecretButton shape. That
doesn't make sense. You need to click on a button that actually calls the
code to show the SecretButton. If the secret button is hidden, it
wouldn't make sense to have that code only called from the hidden button
because you can't click on a hidden button.

Also, I see from your code that you are using Control shapes, not regular
autoshapes. That might change things a bit.

--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

Hi David,

I've re-analyzed your examples, and now it works fine. Great!

Thank you all very much for your help.. and patience.

Best,

Serge
 
D

David M. Marcovitz

That's great! I'm glad you figured it out. Thanks for letting us know.
--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

No problem!
I have one more question. As you see in the below code, the shape "OK"
appears when you click on button SAVE.. and dissapears when you click on that
shape ("HideSecretButton" procedure). But it would be helpful to also have an
option to make it dissaper by itself. I tried to play with your examples'
codes, but it didn't work. Can you advise me on what procedure should I
insert (and exactly where in this code?) to make this "OK" shape stay for 2
seconds and dissapear by itself?

My current code is:

Sub PseudoKeyboard(oSh As Shape)

Dim strShapeText As String
strShapeText = oSh.TextFrame.TextRange.Text

With ActivePresentation.Slides(1).Shapes("TextBox1")
With .OLEFormat.Object
Select Case oSh.TextFrame.TextRange.Text

Case Is = "Backspace"
' delete the last character
.Text = Left$(.Text, Len(.Text) - 1)
Case Else
.Text = .Text & strShapeText
End Select
End With
End With
End Sub

Sub SaveMe()
' ALL ON ONE LINE:
Call WriteStringToFile("C:\Temp\Infofile.txt",
ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text)
' add this after writing the text to file:
ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text = ""
' Substitute the path/file.ext you want to use above
ActivePresentation.SlideShowWindow.View.Slide.Shapes("SecretButton") _
.TextFrame.TextRange.Text = "OK!"

ActivePresentation.SlideShowWindow.View.Slide.Shapes("SecretButton").Visible
= True

End Sub

Sub WriteStringToFile(pFileName As String, pString As String)

Dim intFileNum As Integer
intFileNum = FreeFile
Open pFileName For Append As intFileNum
Print #intFileNum, pString
Close intFileNum
End Sub

Sub SetObjectName()
Dim objectName As String
If ActiveWindow.Selection.Type = ppSelectionShapes _
Or ActiveWindow.Selection.Type = ppSelectionText Then
If ActiveWindow.Selection.ShapeRange.Count = 1 Then
objectName = InputBox(prompt:="Type a name for the object")
objectName = Trim(objectName)
If objectName = "" Then
MsgBox ("You did not type anything. " & _
"The name will remain " & _
ActiveWindow.Selection.ShapeRange.Name)
Else
ActiveWindow.Selection.ShapeRange.Name = objectName
End If
Else
MsgBox _
("You can not name more than one shape at a time. " _
& "Select only one shape and try again.")
End If
Else
MsgBox ("No shapes are selected.")
End If
End Sub

Sub HideSecretButton()
ActivePresentation.Slides(1).Shapes("SecretButton").Visible = False

End Sub
 
D

David M. Marcovitz

Something like this:

Sub SaveMe()
' ALL ON ONE LINE:
Call WriteStringToFile("C:\Temp\Infofile.txt",
ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text)
' add this after writing the text to file:
ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Text =
""
' Substitute the path/file.ext you want to use above
ActivePresentation.SlideShowWindow.View.Slide.Shapes("SecretButton") _
.TextFrame.TextRange.Text = "OK!"

ActivePresentation.SlideShowWindow.View.Slide.Shapes
("SecretButton").Visible
= True

Wait2Seconds

ActivePresentation.SlideShowWindow.View.Slide.Shapes
("SecretButton").Visible
= False


End Sub

Sub Wait2Seconds()
waitTime = 2
Start = Timer
While Timer < Start + waitTime
DoEvents
Wend
End Sub



--
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

Hi David,

Thanks a lot - it works perfect!

I'm also trying to make a music track play throughout the whole presentation
(I use MS Office 2007), so I guess I have to go to Animation -> Slide
Transition -> Loop Until Next Sound.. and then Other Sound and choose a track
in .WAV format?
But how do I make several track keep playing in loop? And could you
recommend a safe free converter site to convert MP3s (and other) into WAV?
Should I post this question in a new thread, for others to get a tip too?

Thank you again, guys, you're very helpful..

Serge
 
D

David M. Marcovitz

You're out of my area of expertise. If no one responds in this thread,
you might try a totally new thread as this is a totally new question.
Most of the people who might know the answer probably stopped reading
this thread several days ago, at the first sight of VBA code.
--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