PDA

View Full Version : Setting Variable from user text box



Orlo
09-05-2017, 07:53 AM
Hi! I'm new to VBA and i'm trying to build a card game on powerpoint. The game deliver cards from a range of slides (2-10 for example) to all players before it passes to another range of cards (10-15)

I have a textbox that users may fill with the number of players they are. I want to use that value so the players simply push 'next card' and automatically changing to the next range after all the players have received a card. So if they are 5, they will get 5 random cards from the first range and then start getting from the other range of slides, etc.

This is for an urgent work, i'd be happy to explain more details if necessary.

Thanks!

SamT
09-05-2017, 02:01 PM
Dim VarNumUsers As Long
VarNumUsers = txbxNumUsers.Value

Orlo
09-05-2017, 07:37 PM
Hey Sam, thanks for the answer, but since i'm new at this I will be needing a bit more help :stars:. Specially since the developing environment it's a bit weird.

I tried what you said (and many other things such as CInt or Val), but i'm having difficulties identifying the objects and getting a 424 error. The VBA project window shows tons of slides objects that don't even exist, one says slide 71 and my presentation only has 62 so far. So I don't know how to actually identify my textbox or how to delete these mysterious objects.

Sorry for the trouble and thanks a lot!

SamT
09-06-2017, 08:22 AM
I don't use PP, but some research suggests that you may have some hidden Slides.

Slides don't have a visible Property, but Shapes do.
Something like this may make all Slides visible. :dunno:

Sub Trying()
Dim Sld As Object
Dim Shp As Object

For Each Sld in Slides
For Each Shp in Sld.Shapes
Shp.Visible = msoTrue
Next
next
End sub

John Wilson
09-06-2017, 11:34 PM
The naming of Slide Containers is not simple. The crucial thing to understand is that once set it the name does not change. This means that the Slide Object named Slide1 may not be actually of the first slide! Confusing!

To get the name of the slide object for eg an ActiveX text box right click > View code and the correct Object name will highlight.

If TextBox1 or whatever is physically on slide 1 you can also say


MsgBox ActivePresentation.Slides(1).Shapes("TextBox1").OLEFormat.Object.Value