On-screen keyboard on PP 2003/2007 presentation?

S

Steve Rindsberg

I read some of your seminars about VB on your website - pretty interesting..
I guess I'm getting a bigger picture, little by little..

Thanks ... it does take a while if you're starting from scratch.
1. BACKSPACE key issue. I have created a new module with the last code you
gave me, named it "Backspace" and assigned it to the BACKSPACE "key" shape.
Now this "key" doesn't type this word in the textbox, nothing happents, and
it doesn't delete the last character.

Pesky aircode. Try this instead, and for extra credit, tell me why it works better than the original <G>.


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

2. SAVE button issue. I read thru your "Geberal Purpose..." and did it all.
When I press F5 - the notepad pops-up with the text I inserted in the code,
and it sends it to the TEMP folder. 1) But it's all happening in VB, not on
the presentation. 2) Now, how to give the button SAVE a command to send the
text typed in the textbox right to that TEMP folder, without popping-up
anywhere, and emptying the text box?

Assign its click action as Run Macro: SaveMe

Sub SaveMe()
' ALL ON ONE LINE:
Call WriteStringToFile("C:\Temp\BlahBlah.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
 
S

Steve Rindsberg

Hi again, Serge

This on-screen keyobard seemed like the kind of thing that might be useful to more people so I've pulled some of
the bits of code together in an example PPT file:

Add an On-Screen Keyboard to your presentation
http://www.pptfaq.com/FAQ00895.htm
 
G

Guest

Hi Steve,
It doesn't work.
1) Should this code be assigned to all "keys" or only to BACKSPACE "key"?:

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

I assign it to the BACKSPACE "key", and it still doesn't backspace.

2) I assigned my SAVE button's click action as Run Macro: SaveMe

Sub SaveMe()
' ALL ON ONE LINE:
Call WriteStringToFile("C:\Temp\BlahBlah.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

.... and I changed the path to C:\Temp\Testfile.txt, and it doesn't save text
in this file.

Your On-screen Keyboard sample works fine. I can just use it for the
Backspace issue. But should I do with the SAVE issue?

Any suggestions?

Sorry for confusion,
Serge
 
G

Guest

Hi again Steve,

I've handled the BACKSPACE issue, but still cannot resolve the SAVE button
problem. Once I change the path/file.ext from your "C:\Temp\BlahBlah.txt"
(below), to my "C:\Temp\Infofile.txt", a little textbox pops-up saying
"Expected: expression".
I tried to read Help on that, but I'm still far from understanding stuff
like "..you may have forgotten to specify a value for a named argument.." and
how to correct that.

Do you know how to correct it? I just want the SAVE button to send the
contact info, users type in the textbox, to my "Infofile.txt" file, and once
it's saved there, the textbox on presentation should become empty again for
the next user. Is it possible?

Thank you for your patience,
Serge
 
S

Steve Rindsberg

Hi again Steve,

I've handled the BACKSPACE issue, but still cannot resolve the SAVE button
problem. Once I change the path/file.ext from your "C:\Temp\BlahBlah.txt"
(below), to my "C:\Temp\Infofile.txt", a little textbox pops-up saying
"Expected: expression".
I tried to read Help on that, but I'm still far from understanding stuff
like "..you may have forgotten to specify a value for a named argument.." and
how to correct that.

Do you know how to correct it? I just want the SAVE button to send the
contact info, users type in the textbox, to my "Infofile.txt" file, and once
it's saved there, the textbox on presentation should become empty again for
the next user. Is it possible?

Sure, but let's start by posting the exact code you have to date.
 
G

Guest

Sure, but let's start by posting the exact code you have to date.

Hi, this is what I have to date:

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

Thank you..
 
S

Steve Rindsberg

This works fine here.

Do you actually have a textbox control named "TextBox1" on Slide 1?
 
G

Guest

Hi again, Serge
This on-screen keyobard seemed like the kind of thing that might be useful to more people so I've pulled some of the bits of code together in an example PPT file:

Add an On-Screen Keyboard to your presentation
http://www.pptfaq.com/FAQ00895.htm

Hi Steve,

I also thought that maybe you could post a similar "on-screen keyboard"
sample (as you suggest above) but with a shape "SAVE" (or "SUBMIT") and its
assigned macro to make it send the info from the text-box to a specified
file. That's the ultimate reason of having the on-screen keyboard - to
collect info, so it would be also useful for more people.

Thank you,

Serge

:
 
S

Steve Rindsberg

Hi Steve,

I also thought that maybe you could post a similar "on-screen keyboard"
sample (as you suggest above) but with a shape "SAVE" (or "SUBMIT") and its
assigned macro to make it send the info from the text-box to a specified
file. That's the ultimate reason of having the on-screen keyboard - to
collect info, so it would be also useful for more people.

You can use this to write to a file:

General-purpose routine for writing a string to a text file
http://www.pptfaq.com/FAQ00514.htm

Adding a button and setting a macro to call it should be simple enough
 
G

Guest

Hi Steve,
I'm sorry for the headache - I finally (!) found the reason (a syntax error)
that prevented that code to execute the command. The code works fine now.
But how to empty the text-box for the next user, once the info is saved?
E.g. if I try to collect attendies' contact info: how to make the info, that
was typed and submitted by one user, dissappear from text-box once this
info's been sent to my file, to let the next user type his/her info too?

Thanks again,

Serge
 
S

Steve Rindsberg

Hi Steve,
I'm sorry for the headache - I finally (!) found the reason (a syntax error)
that prevented that code to execute the command. The code works fine now.
But how to empty the text-box for the next user, once the info is saved?
E.g. if I try to collect attendies' contact info: how to make the info, that
was typed and submitted by one user, dissappear from text-box once this
info's been sent to my file, to let the next user type his/her info too?

Off top of head:
At the end of the routine that writes the text out to a file, set the text box's .TextFrame.TextRange.Text=""
 

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