Jay
Wed Dec 14 12:34:35 CST 2005
The ComboBox control doesn't store any of its information in the document
file. You have to reload it every time you create or open the document. That
means your initialization code must be in the Document_New() and
Document_Open() procedures, not in the ComboBox1_Change() procedure.
To make maintenance a bit easier, put the code into a separate procedure (so
all the AddItem calls are only in one place) and call that procedure from
both Document_New() and Document_Open().
Also, your code is going to add three complete sets of abbreviations to the
ComboBox's list -- I don't think you really want to do that. Remove the For
and Next statements.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ:
http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
Pratchmg wrote:
> I'm trying to put a combo box into a word document in VBA. This is
> my code
>
> Private Sub ComboBox1_Change()
> With ComboBox1
> For ComboBox = 1 To 3
> .AddItem "Mr"
> .AddItem "Mrs"
> .AddItem "Ms"
> Next ComboBox
> End With
>
> End Sub
>
> When I reopen the doccument, the menu items disappear. Would anyone
> have any suggestions ?