Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Refer to a control using VB (PPT 2000)

    I have a blank action button on a slide, and a text box called "PCase" created from the toolbox, also on the slide.

    When a user enters text into the text box "PCase" and clicks on the action button, I want code to test that the text entered in "PCase" is correct.
    How do I refer to "PCase"?

    I tried something like:
    if me.Pcase = "Correct" then
    goto slide 24
    end if

    but it doesn't work. How can I do this and then attach the code to the action button which only seems to access macros and not code?

    Many thanks for your help.

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Refer to a control using VB (PPT 2000)

    I thought, here is an easy problem. I was wrong (many times), but I finally figured it out. Even though the Action settings call the action "Run macro", that is not exactly correct. After you put an ActionButton on a slide, you will notice in your VBA project that you have new module added to your PowerPoint objects, called Sliden, where n is the slide number (first slide is 1 not 0). You place the "macro" for the button in this module and add Public to the sub declaration. Then you can right-click on the button, select Action Settings, and assign the "macro." Here is the code that I used. I have also attached my test presentation since this is pretty confusing. When programming PoPo, you lose what little hair you have left. The Demo presentation has one ugly feature: the first click on the action button does not depress it, the first one removes the focus from the textbox, the second click depresses the button. One final hint, the object model changes when you run the presentation, so macros recorded while creatinf the presentation will not work when viewing the show. However, you can start the macro recorder before you start the show and then most of what you do in the show will be recorded. HTH! --Sam
    <pre>Option Explicit

    Public Sub ckPCase()
    If PCase.Text = "Correct" Then
    SlideShowWindows(1).View.GotoSlide 3
    PCase.Text = ""
    Else
    MsgBox "Try Again!"
    End If
    End Sub</pre>

    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Refer to a control using VB (PPT 2000)

    SammyB,

    Thanks so much - works like a dream.

Posting Permissions

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