Store contents of combobox in Word file

I have a word document that has a combobox on it.  I am currently populating the combobox with multiple collumns from a ADSI query.  I would like to save the combobox contents within the word file so that I can send the word document to others without the need for any additional source files, database connections or anything (I want to programatically populate the combobox initially and then allow users to see the "cached" combobox contents).  

Ideally there'd by a programatic way to
1.  Take my existing contents of the combobox and store them in a hidden area or array in the document
2.  allow the document to be saved with the data
3.  Automatically repopulate the combobox with the stored information.

LVL 2
btreeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jayneeConnect With a Mentor IT ManagerCommented:
What sort of data are you talking about?  If there's not too many items, you might consider writing them as custom properties (see File\Properties\Custom for the sort of thing I mean).  Just create each item as a property according to a unique naming scheme when you first load the combobox, then programatically pull them back out when you want to populate.
0
 
twardCommented:
Could you use something like this in the VBA of the Word Document?

 

Private Sub Document_Open()
 
  Dim Counter As Long
 
  For Counter = 1 To 100
     
     Me.ComboBox1.AddItem ("TEST " & Format(Counter, "000"))
 
  Next Counter
 
End Sub
0
 
btreeAuthor Commented:
I am familiar with the .additem to populate the combobox, however once the combobox is populated I want to take the contents and store them in the word document so that I can then re-populate the combobox the next time the document is opened.  It is my understanding that a combobox's contents are not saved with the document and the combobox must be populated everytime the document is opened.
0
 
jayneeIT ManagerCommented:
Or you could muck about with a range of hidden text (perhaps one line per combobox item), where you set the font property to Hidden.  This would be messier, and users who had their Word options set to see all non-printing characters would still see the hiden text.
0
 
btreeAuthor Commented:
The type of data is contact information such as first name, last name, email address, mailing address.  There would be 5 - 100 names and addresses.  I realize I could link to an external file such as an excel sheet but I would like to be able to send this one word document only to those who need to use it.  Would Jaynee's method work for this?
0
All Courses

From novice to tech pro — start learning today.