Group:  Microsoft Word ยป microsoft.public.word.vba.userforms
Thread: Drop down menu

Geek News

Drop down menu
parkin_m 5/30/2007 4:40:03 PM
Hi again!

I have a drop down menu that I would like to fill with "January, Feburary,
March.. etc"

I have the dropdown menu inside a form. Would a list box or a combo box be
better?

Also how do I actually fill the box with the dates? (I dont want to link to
some external place since the months will never change)
Re: Drop down menu
"Jay Freedman" <jay.freedman[ at ]verizon.net> 5/30/2007 5:55:55 PM
First, a couple of questions whose answers will determine what kind of
advice you need:

- What kind of "form" is this? A "protected form" with fields from the Forms
toolbar? A VBA-driven userform? Something else, such as an unprotected
document?

- What do you mean by a "drop down menu"? What behavior do you want?

In a protected form, you can have a "dropdown form field" but there is no
list box or combo box. In a VBA userform you can have either a list box or a
combo box, and the combo box can be limited so the user can only choose the
entries you supplied. In a nonprotected document, the object of choice is an
AutoTextList field. You could use a combo box from the Control Toolbox, but
that's more trouble than it's worth.

Trying to describe the "how" would be a waste of time until you choose the
"what".

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

parkin_m wrote:
[Quoted Text]
> Hi again!
>
> I have a drop down menu that I would like to fill with "January,
> Feburary, March.. etc"
>
> I have the dropdown menu inside a form. Would a list box or a combo
> box be better?
>
> Also how do I actually fill the box with the dates? (I dont want to
> link to some external place since the months will never change)


Re: Drop down menu
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 5/30/2007 5:56:15 PM
Probably a combobox would be the most conventional for the user to be able
to select use one month.

Assuming that your combobox is name cmbMonth, you would load it with the
months by using

With cmbMonth
.AddItem "January"
.AddItem "February"


.AddItem "November"
.AddItem "December"
End With

In most probably the Initialize() event of your form.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"parkin_m" <parkinm[ at ]discussions.microsoft.com> wrote in message
news:F252714F-392C-4D49-8194-B2B4B10C207D[ at ]microsoft.com...
[Quoted Text]
> Hi again!
>
> I have a drop down menu that I would like to fill with "January, Feburary,
> March.. etc"
>
> I have the dropdown menu inside a form. Would a list box or a combo box be
> better?
>
> Also how do I actually fill the box with the dates? (I dont want to link
> to
> some external place since the months will never change)


Re: Drop down menu
parkin_m 5/31/2007 10:32:01 AM
This is exactly what I ment, thank you.

I now have the combo box populated with the correct months in the
UserForm_Initalize() event.

How do I then add the selected option to my bookmark?
This is what I had previously:

With ActiveDocument
.Bookmarks("month").Range _
.InsertAfter month
End With

It is now not working. Do I need to do some kind of case statement to find
out which month was selected?

Thanks




"Doug Robbins - Word MVP" wrote:

[Quoted Text]
> Probably a combobox would be the most conventional for the user to be able
> to select use one month.
>
> Assuming that your combobox is name cmbMonth, you would load it with the
> months by using
>
> With cmbMonth
> .AddItem "January"
> .AddItem "February"
>
>
> .AddItem "November"
> .AddItem "December"
> End With
>
> In most probably the Initialize() event of your form.
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "parkin_m" <parkinm[ at ]discussions.microsoft.com> wrote in message
> news:F252714F-392C-4D49-8194-B2B4B10C207D[ at ]microsoft.com...
> > Hi again!
> >
> > I have a drop down menu that I would like to fill with "January, Feburary,
> > March.. etc"
> >
> > I have the dropdown menu inside a form. Would a list box or a combo box be
> > better?
> >
> > Also how do I actually fill the box with the dates? (I dont want to link
> > to
> > some external place since the months will never change)
>
>
>
Re: Drop down menu
"Jay Freedman" <jay.freedman[ at ]verizon.net> 5/31/2007 1:46:19 PM
Following on from Doug's assumption that the combo box is named cmbMonth,
you need to use that name to get the combo's selection:

With ActiveDocument
.Bookmarks("month").Range _
.InsertAfter cmbMonth.Value
End With

You might also want to have a look at
http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

parkin_m wrote:
[Quoted Text]
> This is exactly what I ment, thank you.
>
> I now have the combo box populated with the correct months in the
> UserForm_Initalize() event.
>
> How do I then add the selected option to my bookmark?
> This is what I had previously:
>
> With ActiveDocument
> .Bookmarks("month").Range _
> .InsertAfter month
> End With
>
> It is now not working. Do I need to do some kind of case statement
> to find out which month was selected?
>
> Thanks
>
>
>
>
> "Doug Robbins - Word MVP" wrote:
>
>> Probably a combobox would be the most conventional for the user to
>> be able to select use one month.
>>
>> Assuming that your combobox is name cmbMonth, you would load it with
>> the months by using
>>
>> With cmbMonth
>> .AddItem "January"
>> .AddItem "February"
>>
>>
>> .AddItem "November"
>> .AddItem "December"
>> End With
>>
>> In most probably the Initialize() event of your form.
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "parkin_m" <parkinm[ at ]discussions.microsoft.com> wrote in message
>> news:F252714F-392C-4D49-8194-B2B4B10C207D[ at ]microsoft.com...
>>> Hi again!
>>>
>>> I have a drop down menu that I would like to fill with "January,
>>> Feburary, March.. etc"
>>>
>>> I have the dropdown menu inside a form. Would a list box or a combo
>>> box be better?
>>>
>>> Also how do I actually fill the box with the dates? (I dont want to
>>> link to
>>> some external place since the months will never change)


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net