Consulting

Results 1 to 4 of 4

Thread: Making a common change to slide.controls

  1. #1
    VBAX Contributor
    Joined
    Apr 2014
    Posts
    109
    Location

    Making a common change to slide.controls

    Hello...

    I hope this hasn't already been addressed... been searching for answers most of the day.
    I am developing a non-profit training module for our volunteers. The module has 6 sections with a short multiple choice quiz at the end of each.
    Since I copied the slides, the answer textbox is named the same on every slide. After submitting the answer, I disabled the box. If the user decides to redo the section he/she would need to select a button and every textbox in that section would be enabled and the answer within it emptied. Since it includes a lot of repetition I wanted to refer to the slide as an object. That in itself raised a different problem because I didn't create the slides in regular order and so for example, the 16th slide is numbered as "Slide19" in the VBA list of PowerPoint Objects. I have learned that there is a way to refer to Slide19 and also to slide(16).... not that this erases the confusion.

    Here is the code I have so far...

    Sub Reset2()
    Dim osl As Slide
    Dim myct As Integer
    For myct = 38 To 42
    Set osl = Me.Controls("Slide" & CStr(myct)) 'Me doesn't work - nor did anything else I tried here
    With osl
    .TextBox1.Value = "" 'doesn't recognize TextBox1
    .TextBox1.Enabled = True
    "do more stuff here"
    End With
    Next
    End Sub


    The following works.... but with all my slides it will be a lot of code, especially since I have only given you 2 items where there is actually a slightly longer list of "do more stuff". Any help to consolidate this code would be appreciated.

    Sub Reset2()
    With Slide38
    .TextBox1.Value = ""
    .TextBox1.Enabled = True
    End With
    Next
    With Slide39
    .TextBox1.Value = ""
    .TextBox1.Enabled = True
    End With
    Next
    With Slide40
    .TextBox1.Value = ""
    .TextBox1.Enabled = True
    End With
    Next
    With Slide41
    .TextBox1.Value = ""
    .TextBox1.Enabled = True
    End With
    Next
    With Slide42
    .TextBox1.Value = ""
    .TextBox1.Enabled = True
    End With
    Next
    End Sub


    Thanks
    Gary

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Not quite sure what you need but if you want to refer to the CURRENT slide (in show mode). NOTE how you refer to ActivX TextBoxes using the name and OLEFormat.
    Dim osld as Slide
    set osld=SlideShowWindows(1).View.Slide
    With osld
    On Error Resume Next
    'Whatever
    osld.Shapes("TextBox1").OLEFormat.Object.Text = ""
    osld.Shapes("TextBox1").OLEFormat.Object.Enabled = False
    End With

    To reset all slides

    Dim osld as Slide
    For each osld in ActivePresentation.Slides
    On Error Resume Next ' in case there is no Textbox1
    'Do Whatever
    osld.Shapes("TextBox1").OLEFormat.Object.Text = ""
    osld.Shapes("TextBox1").OLEFormat.Object.Enabled = False
    Next
    Last edited by John Wilson; 04-06-2014 at 05:25 AM.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Contributor
    Joined
    Apr 2014
    Posts
    109
    Location
    Thanks John...
    Your response was close enough to what I was looking for, that I was able to make the adjustments. I was trying to reset 5 slides only at a time, depending on which section the user wants to redo. So I now have Reset1, Reset2, Reset3, etc, which set the sldstart value and send to ResetNow which is like this. And it works

    Sub ResetNow()
    For myct = sldstart To sldstart + 4
    With ActivePresentation.Slides(myct)
    .Shapes("TextBox1").OLEFormat.Object.Text = ""
    .Shapes("TextBox1").OLEFormat.Object.Enabled = True
    .Shapes("CmdSubmit").OLEFormat.Object.Enabled = True
    .Shapes.Item("HiLite").Visible = False
    End With
    Next
    End Sub

    Gary
    Attached Images Attached Images

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Glad it helped. Usually in PPT it's best to avoid ActivX TextBoxes alltogether but if you need the user to type into them during a show there's no alternative. In most other cases they are not needed.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

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