Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

Listbox empties when closing document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Armelderoeck - 02 Nov 2006 09:58 GMT
I have created a listbox in a word doc. When I work on this document, the
listbox is filled in. But if I save, close then open the doc again, the
listbox empties. How can I avoid that?
Thanks.
Jean-Guy Marcil - 04 Nov 2006 06:04 GMT
Armelderoeck was telling us:
Armelderoeck nous racontait que :

> I have created a listbox in a word doc. When I work on this document,
> the listbox is filled in. But if I save, close then open the doc
> again, the listbox empties. How can I avoid that?
> Thanks.

Where is this listbox exactly?
How was it created and filled in the first place?
What Word version?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Armelderoeck - 04 Nov 2006 09:49 GMT
> Armelderoeck was telling us:
> Armelderoeck nous racontait que :
[quoted text clipped - 7 lines]
> How was it created and filled in the first place?
> What Word version?

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,

A plus!
Jean-Guy Marcil - 04 Nov 2006 17:43 GMT
Armelderoeck was telling us:
Armelderoeck nous racontait que :

>> Armelderoeck was telling us:
>> Armelderoeck nous racontait que :
[quoted text clipped - 27 lines]
>
> 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.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.