Armelderoeck was telling us:
Armelderoeck nous racontait que :
The list box is in my Word doc, included in the text (placed in a
table). I just created it under Word 2007 with the 'developper'
section, with the simple control that is furbished in this view.
For the moment, I use the solution hereafter:
When closing the docx, a macro runs and fills a text box, turning the
contents of my listbox into a XML format.
Another macro is launched when opening the docx that 'reads' the XML
and fills in the listbox again.
So, on my side, I have solved the problem, but some other people
could have it...
Another thing: why does Word bugs when I use the mouse wheel over the
listbox???
Thanks for your answer anyway,
If you add content through VBA, the content will be gone when you next open
the document, except for the item that might have been chosen by the user.
If you do not want to use XML, you have two options:
VBA:
'_______________________________________
Private Sub Document_New()
FillDropDown
End Sub
'_______________________________________
'_______________________________________
Private Sub Document_Open()
FillDropDown
End Sub
'_______________________________________
'_______________________________________
Sub FillDropDown()
Dim cctrlDrop As ContentControl
Set cctrlDrop = ActiveDocument.Tables(1).Range.ContentControls(1)
With cctrlDrop
.Title = "List Test"
.SetPlaceholderText , , "List filled when creating/opening document."
.DropdownListEntries.Add "Option 1"
.DropdownListEntries.Add "Option 2"
.DropdownListEntries.Add "Option 3"
.DropdownListEntries.Add "Option 4"
End With
End Sub
'_______________________________________
GUI:
Insert your Dropdown, select it, then on the Developer tab, click on
"Properties"
Use the Add button to add your entries.
When you are done (Or before, it does not matter when), you may want to lock
the control down. But this has no bearing on list content retention from one
Word session to the next.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org