PDA

View Full Version : Solved: How do I make a simple drop down menu with 4 options?



jamieCR9
09-25-2009, 05:54 PM
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! :)

John Wilson
10-07-2009, 01:20 AM
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:

With Me.ComboBox1
.Clear
.AddItem "Mastercard"
.AddItem "Maestro"
.AddItem "Visa"
.AddItem "American Express"
End With

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 .....

jamieCR9
10-08-2009, 09:18 AM
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!

John Wilson
10-08-2009, 09:29 AM
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)

Private Sub CommandButton1_Click()
ActivePresentation.Slides(2).Shapes(3).TextFrame.TextRange = Me.ComboBox1.Text
End Sub

jamieCR9
10-08-2009, 12:46 PM
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.

John Wilson
10-09-2009, 03:37 AM
Did the original code work OK?

I get some problems and this is better here

If Me.ComboBox1.ListCount <> 4 Then
With Me.ComboBox1
.AddItem "Mastercard"
.AddItem "Maestro"
.AddItem "Visa"
.AddItem "American Express"
End With
End If

jamieCR9
10-09-2009, 07:11 AM
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. :)