Consulting

Results 1 to 8 of 8

Thread: VBA PowePoint Images Help

  1. #1

    VBA PowePoint Images Help

    Complete Beginner here, I have a PowerPoint presentation which I need to code some VB into.
    Basically I have a form that opens when the user opens the presentation with two different options. Depending on which option is chosen certain pictures during the presentation will be shown. Where there is pics there is 1 for each option chosen they are the exact same size and on top of each other. I have my form made up with the selection box but not sure how to link it up to the pictures which are to become visible/invisible
    Any help would be greatly appreciated.

  2. #2
    Here is what I have so far, but am getting an error "Else without If"??

    Does this look correct for what I want to do? Just trying to get something working now thats why I have them both set to false.

    [VBA]Public Sub populate()
    mdlContentCombo.AddItem "IIW", 0
    mdlContentCombo.AddItem "BDW", 1
    End Sub


    Private Sub okBtn_Click()
    selection = mdlContentCombo.Value

    If selection = O Then ActivePresentation.Slides(10).Shapes("Picture 4").Visible = False

    Else
    ActivePresentation.Slides(10).Shapes("Picture 4").Visible = False
    End If

    hide
    End Sub[/VBA]

  3. #3
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Quote Originally Posted by jaybeeb
    Here is what I have so far, but am getting an error "Else without If"??

    Does this look correct for what I want to do? Just trying to get something working now thats why I have them both set to false.

    [vba]Public Sub populate()
    mdlContentCombo.AddItem "IIW", 0
    mdlContentCombo.AddItem "BDW", 1
    End Sub


    Private Sub okBtn_Click()
    selection = mdlContentCombo.Value

    If selection = O Then ActivePresentation.Slides(10).Shapes("Picture 4").Visible = False

    Else
    ActivePresentation.Slides(10).Shapes("Picture 4").Visible = False
    End If

    hide
    End Sub[/vba]
    You ned to change to this

    [vba]
    Public Sub populate()
    mdlContentCombo.AddItem "IIW", 0
    mdlContentCombo.AddItem "BDW", 1
    End Sub


    Private Sub okBtn_Click()
    selection = mdlContentCombo.Value

    If selection = O Then
    ActivePresentation.Slides(10).Shapes("Picture 4").Visible = False

    Else
    ActivePresentation.Slides(10).Shapes("Picture 4").Visible = False
    End If

    hide
    End Sub
    [/vba]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  4. #4
    Thanks John, could you tell me what you think is the best way of doing this as it still is not working properly the way I have it. When I run the macro and one of the images dissapears. It stays as visible = false so the image doesnt appear again.

  5. #5
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Quote Originally Posted by jaybeeb
    Thanks John, could you tell me what you think is the best way of doing this as it still is not working properly the way I have it. When I run the macro and one of the images dissapears. It stays as visible = false so the image doesnt appear again.
    I would move the correct picture in front of the other.

    [vba]If Selection = O Then
    ActivePresentation.Slides(10).Shapes("Picture 4").ZOrder (msoBringToFront)

    Else
    ActivePresentation.Slides(10).Shapes("Picture 4").ZOrder (msoBringToFront)
    End If[/vba]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  6. #6
    John, thanks for the help - yes that is a much nicer idea. But the problem I am having now is even if the condition is true it will still only run the 'else' statement?

    Here is my code now as it stands:


    [vba]
    Public Sub populate()
    mdlContentCombo.AddItem "HPDM", 0
    mdlContentCombo.AddItem "BDW", 1
    End Sub


    Private Sub okBtn_Click()
    selection = mdlContentCombo.Value

    If selection = "0" Then
    ActivePresentation.Slides(10).Shapes("Picture 5").ZOrder (msoBringToFront)

    Else
    ActivePresentation.Slides(10).Shapes("Picture 4").ZOrder (msoBringToFront)
    End If

    hide
    End Sub
    [/vba]

  7. #7
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    [vba]If strselec = "HPDM" Then
    [/vba]

    Remove the hide
    Don't use selection its a reserved word
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  8. #8
    Fair Play John. Thats spot on!

Posting Permissions

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