Consulting

Results 1 to 5 of 5

Thread: Setting Variable from user text box

  1. #1
    VBAX Newbie
    Joined
    Sep 2017
    Posts
    2
    Location

    Setting Variable from user text box

    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!

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Dim VarNumUsers As Long
    VarNumUsers = txbxNumUsers.Value
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Newbie
    Joined
    Sep 2017
    Posts
    2
    Location
    Hey Sam, thanks for the answer, but since i'm new at this I will be needing a bit more help . 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!

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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. :
    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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    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
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •