Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PowerPoint Textbox control 3

Status
Not open for further replies.

misscrf

Technical User
Jun 7, 2004
1,344
US
I have various textbox controls on a powerpoint. At the end of the presentation, I want their value to be nothing, so that when I open it the next time, it is clean. I created a "The End" command button, but none of the code I have tried works.

I tried

textbox1.value = ""
textbox1.text = ""

I compiles ok, but then gives me a debug error.

:-(

Does anyone know the trick to this?

Thanks,

misscrf

It is never too late to become what you could have been ~ George Eliot
 
gives me a debug error
Which error ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Runtime error '424':
Object Required.

The thing is there is a TextBox1 on 1 slide and a TextBox1 on another slide.

There are like 5 textboxes in the presentation either named TextBox1 or TextBox3.

I need all of them reset to no value.

Any thoughts?

Thanks,

misscrf

It is never too late to become what you could have been ~ George Eliot
 



Each Textbox has a Slide object.

Please post your code AND please indicate the STATEMENT on which you got the error.

Skip,

[glasses] [red][/red]
[tongue]
 
You can't qualify the controls with their parent's name ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you for both of your responses.

Here is the code that I have:

Code:
Private Sub CommandButton1_Click()
TextBox1.Value = ""
TextBox3.Value = ""
End Sub

The thing is, this button is on the last slide. The slide that a textbox may be on could be 10 or 15 as I look at it, but I don't know how to tell what the right slide index is. I have looked up in help how to say what textbox on what slide, but that isnt getting it either.

I just want all of the textbox controls in the active presentation to have no value when I click that button on the last slide, no matter what slide any of them are on.

Thank you.

misscrf

It is never too late to become what you could have been ~ George Eliot
 


Why not something like this
Code:
dim sld as slide, shp as shape
for each sld in activepresentation.slides
  for each shp in sld.shapes
    shp.oleformat.object.value = ""
  next
next


Skip,

[glasses] [red][/red]
[tongue]
 
Thank you. I tried this at one point, but a textbox control is not a shape so it errors on this.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
I would post the following, but Skip beats me ...
For Each mySlide In ActivePresentation.Slides
For Each myShape In mySlide.Shapes
If myShape.Type = msoTextBox Then
myShape.TextFrame.TextRange.Text = ""
End If
Next
Next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 



Use your Watch Window to DISCOVER the properties you need.

How to use the Watch Window as a Power Programming Tool faq707-4594

Skip,

[glasses] [red][/red]
[tongue]
 
How are the textboxes populated during the presentation ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
A listbox has choices, then the person watching the presentation chooses an option. On click of the listbox, the textbox will = certain text.

That all works. By the end of the presenation, all the textboxes have leftover text of the right answers for any slide that had a question.

I found code to find what the slide names and textbox controls are and to set them.

I set them to the following (there are 3):

SldA and txtA on that slide
SldB and txtB for the 2nd question slide
SldC and txtC for the last question.


I tried your code:
Code:
For Each mySlide In ActivePresentation.Slides
  For Each myShape In mySlide.Shapes
    If myShape.Type = msoTextBox Then
      myShape.TextFrame.TextRange.Text = ""
    End If
  Next
Next

It doesn't error or anything, but nothing happens to the textbox controls either lol.

To be sure, I am using textbox controls from the vba toolbar, not text frames from the drawing toolbar.

Thank you for your continued help.




misscrf

It is never too late to become what you could have been ~ George Eliot
 



Use your Watch Window to DISCOVER the properties you need.

Use your Watch Window to DISCOVER the properties you need.

Use your Watch Window to DISCOVER the properties you need.

Look back on the code you "discovered" how to use with animation. How was the TEXT assigend there.

ADAPT accordingly!

Skip,

[glasses] [red][/red]
[tongue]
 
There is just no need for that. I don't understand how to use the watch window. It makes no sense to me. I have tried many times. It just says EMPTY. I don't want to ask you to explain it to me because it diverts from my question, I am not asking you to teach me vba, and I don't want to get a rude response like this one. I am not a child, I am a working professional with a question. If you don't respect me, then please don't worry about helping me.

Thank you.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
On click of the listbox, the textbox will = certain text
Any chance you could post this code ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
sure thing.

Here it is:

Code:
Private Sub ListBox1_Click()
If ListBox1 <> "" Then
answer = ListBox1
If answer = "A answer1" Then
txtReportUH = "This answer is wrong. Try again."
txtReportUH.SpecialEffect = fmBorderStyleSingle
txtReportUH.ForeColor = vbBlack
txtReportUH.BackColor = RGB(238, 233, 233)
txtReportUH.BorderColor = vbBlack
ElseIf answer = "B Answer2" Then
txtReportUH = "This is the correct answer"
txtReportUH.SpecialEffect = fmBorderStyleSingle
txtReportUH.ForeColor = vbBlack
txtReportUH.BackColor = RGB(238, 233, 233)
ElseIf answer = "C Answer3" Then
txtReportUH = "Almost. Try again."
txtReportUH.SpecialEffect = fmBorderStyleSingle
txtReportUH.ForeColor = RGB(64, 0, 0)
txtReportUH.BackColor = RGB(238, 233, 233)
ElseIf answer = "D Answer4" Then
txtReportUH = "Close, but no cigar."
txtReportUH.BorderStyle = fmBorderStyleSingle
txtReportUH.BorderColor = vbBlack
txtReportUH.ForeColor = vbBlack
txtReportUH.BackColor = RGB(238, 233, 233)
End If
End If
End Sub

misscrf

It is never too late to become what you could have been ~ George Eliot
 




Code:
With oSomeObject
   x = .SubObject.Value

End With
You can do a watch on
[tt]
oSomeObject
or
oSomeObject.SubObject
or
oSomeObject.SubObject.Value
[/tt]
by either selecting the object/value, right-click and select Add Watch... or filling in the ADD Watch window.

Skip,

[glasses] [red][/red]
[tongue]
 
ok I took this line of code:

Private Sub CommandButton1_Click()
txtA.Text = ""
End Sub

and highlighted txtA.Text and put a watch on it. It says for Value: <out of context>
and
Type: Variant/Empty

Did I do that right?

misscrf

It is never too late to become what you could have been ~ George Eliot
 


"It says for Value: <out of context> "

You must be executing the code within Private Sub CommandButton1_Click()


Skip,

[glasses] [red][/red]
[tongue]
 
ok, now it says <object required> .

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top