Consulting

Results 1 to 7 of 7

Thread: Solved: How do I make a simple drop down menu with 4 options?

  1. #1
    VBAX Regular
    Joined
    Sep 2009
    Posts
    36
    Location

    Question Solved: How do I make a simple drop down menu with 4 options?

    As the title says, how would I be able to create that? All I want is a drop down menu for the user to choose from, and to put in some context it is for a payment option: MasterCard, Maestro, Visa, American Express.

    Any help that can be given is very appreciated!

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    I'm assuming you have put a combobox directly on a slide?

    Right Click > View Code

    You should see two lines of code and above two dropdown menus that (probably) say ComboBox1 and Change. Alter the Change one to "MouseDown"

    Between the NEW lines of code paste this:

    [VBA]With Me.ComboBox1
    .Clear
    .AddItem "Mastercard"
    .AddItem "Maestro"
    .AddItem "Visa"
    .AddItem "American Express"
    End With[/VBA]

    Now you just need to do whatever based on the text in the box

    I would suggest a command button with code like

    If Me.ComboBox1.Text="MasterCard" Then .....
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Regular
    Joined
    Sep 2009
    Posts
    36
    Location
    Thanks I added the code you asked me to, and I just need help with the if part now. I just need to be able to copy the text from the option they picked to a label further on in the PowerPoint. I know I need to code this under a code button, I already have one on the slide, so how would I be able to do this? Thanks John, you're a whizz at this!

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Passing the "answer" to a label on a different slide is less easy. It would be easier to put the text in a nomal shape.

    eg To put the text on shapes(3) on slide (2)

    [VBA]Private Sub CommandButton1_Click()
    ActivePresentation.Slides(2).Shapes(3).TextFrame.TextRange = Me.ComboBox1.Text
    End Sub[/VBA]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    VBAX Regular
    Joined
    Sep 2009
    Posts
    36
    Location
    So should I put that code into the command button and it should work? I don't know what you mean by "shape" though, I thank you in advance for your reply.

    EDIT: I think I got it for now, only problem is people can edit the combobox textbox component, it would be good if they only had the choice in the drop down menu itself.
    Last edited by jamieCR9; 10-08-2009 at 04:37 PM.

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Did the original code work OK?

    I get some problems and this is better here

    [VBA]If Me.ComboBox1.ListCount <> 4 Then
    With Me.ComboBox1
    .AddItem "Mastercard"
    .AddItem "Maestro"
    .AddItem "Visa"
    .AddItem "American Express"
    End With
    End If[/VBA]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  7. #7
    VBAX Regular
    Joined
    Sep 2009
    Posts
    36
    Location
    The original code worked alright at times, although it was quite glitchy at times. For example, when I go to dropdown option "Visa", Mastercard comes up. I will try this new code and let you know how it goes. Thanks.

    EDIT: New code works sooo much better, thank you very much. Now I am going to try and copy the option to a label on another slide, was able to on the other code so I will let you know how it goes.

Posting Permissions

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