Consulting

Results 1 to 6 of 6

Thread: Initializing a control

  1. #1

    Question Initializing a control

    Good Day,

    Please help.... I would like to add item to a combobox when the slide opens. I found the event that is triggered when the slide opens but I do not know how to access the combobox from the event in the modules that I created.

    Public Sub OnSlideShowPageChange()
    if ActivePresentation.SlideShowWindow.View.Slide.SlideIndex = ? then
    ... add items to combobox.
    end if
    End Sub

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    First you have to know where the ComboBox is, then you have to know its Name.
    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 Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Something like this:

    Sub OnSlideShowPageChange(SW As SlideShowWindow)
    Dim osld As Slide
    If SW.View.CurrentShowPosition = 1 Then 'or whatever index
    Set osld = SW.View.Slide
    With osld.Shapes("ComboBox1").OLEFormat.Object ' use the name of the box
    .Clear
    .AddItem "whatever"
    .AddItem "Something else"
    .Value = "whatever"
    End With
    End If
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  4. #4
    Quote Originally Posted by John Wilson View Post
    Something like this:

    Sub OnSlideShowPageChange(SW As SlideShowWindow)
    Dim osld As Slide
    If SW.View.CurrentShowPosition = 1 Then 'or whatever index
    Set osld = SW.View.Slide
    With osld.Shapes("ComboBox1").OLEFormat.Object ' use the name of the box
    .Clear
    .AddItem "whatever"
    .AddItem "Something else"
    .Value = "whatever"
    End With
    End If
    End Sub
    Thanks... much appreciated. However, when I run the code it does not do anything. I put in a msgbox to see if it actually triggers the event but it does not. Do you put this inside a module or a class module?

  5. #5
    I do know where the combobox resides, i.e. which slide and ofcourse the name of the combobox

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    It goes into a normal module and it definitely should work.
    You should be able to download a demo from here

    In the code the combo would need to be on slide 1 so you should alter line 3 if not as it says.
    Last edited by John Wilson; 02-11-2018 at 03:36 AM.
    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
  •