Hello, I am working on a combo box, Visual Basic 6.5 on Microsoft Word 2003. When I put in the text for the combo box, it loads fine. I save, close the document. When I re-open the file, everything in the drop box is gone. What am I doing wrong?

Where does the "text" that populates the combo box come from? Is it from a database or another text file?

I tried everything - a text file, just adding an item...I get the same results. When I run the page, it works great. I save it, close the file, re-open, and everything is gone. Is there a code I am missing? Thank you for your help!

PS - For instance, what would the code for a combo box be that has "Jan.", "Feb.", etc. in it?!

You can add the following code directly to the Document_Open event or you can add it in a stand alone module and call the sub when the document opens.

With ActiveDocument.ComboBox1
.Clear
.AddItem "January"
.AddItem "February"
.AddItem "March" 'And so on......
End With

You can also try the following under the UserForm_Initialize event -

Me.ComboBox1.List = Split("January|February|March") 'And so on...

Thank you for your help. It worked initially, but then when I re-opened the document four or five times later, everything disappeared again. I think there is a "glitch" in the system.

It was a pleasure.:) Happy coding.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.