Mo
Sun Oct 08 06:14:01 CDT 2006
Jean,
Thanks for your help. It has worked.
I might need to post another question for you again.
Regards,
Mo
"Jean-Guy Marcil" wrote:
> Mo was telling us:
> Mo nous racontait que :
>
> > Jean,
> >
> > thanks for replying.
> >
> > i have used the control box to create the combo box.
> > i would like to enter items in there & select them up via the drop
> > down menu.
> >
> > hope this clarifies your questions.
>
> Actually, it clarifies your post... not my questions! ;-)
>
> Here is a simple way:
> While in design mode, right click on the combobox and select "View Code".
> Once in the code pane, paste the first example and play around with it in
> the document to see what happens.
> This is fine if you only have a few items. If you have many items, you may
> want to consider using an array, see the second example for that.
>
> '_______________________________________
> 'Example One
> Private Sub ComboBox1_GotFocus()
>
> Dim lngCurSel As Long
>
> With ComboBox1
> 'Save Current selection
> lngCurSel = .ListIndex
> 'Remove items or we will keep adding them over an over...
> .Clear
> 'Add the items
> .AddItem "Select"
> .AddItem "One"
> .AddItem "Two"
> .AddItem "Three"
> .AddItem "Four"
> 'Reset the selection
> .ListIndex = lngCurSel
> End With
>
> End Sub
> '_______________________________________
>
> '_______________________________________
> 'Example Two
> Private Sub ComboBox1_GotFocus()
>
> Dim varItems As Variant
> Dim lngCurSel As Long
>
> 'Create the array
> varItems = Array("Select", "One", "Two", "Three", "Four", "Five", _
> "Six", "Seven", "Eight", "Nine", "Ten")
>
> With ComboBox1
> 'Save Current selection
> lngCurSel = .ListIndex
> 'Remove items or we will keep adding them over an over...
> .Clear
> 'Add the items
> .List() = varItems
> 'Reset the selection
> .ListIndex = lngCurSel
> End With
>
> End Sub
> '_______________________________________
>
> If I may add a comment, if you plan on distributing your template/document,
> avoid the ACtiveX controls from the Control Toolbox.
> In Word they are unstable and if someone has their security set to High,
> they will be deactivated as they are considered a virus threat (They can
> activate code just by being clicked on...)
>
> See if you can use a protected form instead.
>
> Of course, if your projects requires macros anyway, then the security issue
> becomes irrelevant. Just be aware that there have been numerous reports
> describing difficult to cure problems regarding ActiveX controls. I think
> three things can help you:
> 1) Make sure you give them a name yourself (Do not use the default name as I
> did above with "ComboBox1",
> 2) Do not use too many of tem in one document,
> 3) Create the document using the lowest Word version you want to support.
>
> --
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site:
http://www.word.mvps.org
>
>
>