A
ah
Hi;
I've the following code in my user form currently, and it will auto prompt
the combo box to the user when they open the form. However, the country
selection field will become empty when the user open the form that they have
saved to their local drive by clicking on the "Enable Macro" button. Please
advice what should I do if I want the combo box to be shown only when the
user click on the Country_Name field and not to prompt to the user
automatically when they open the form?
My code details are as follows:
Private Sub ComboBox1_Change()
ActiveDocument.FormFields("Country_Name").Result = ComboBox1.Value
End Sub
Private Sub UserForm_Initialize()
ComboBox1.ColumnCount = 1
'Load data into ComboBox
ComboBox1.List() = Array("Please select from the list", "AUSTRIA",
"BELARUS", "BELGIUM", "BULGARIA", "CROATIA", "CZECH REPUBLIC", "DENMARK",
"EGYPT", "FINLAND", "FRANCE", "GEORGIA", "GERMANY", "GREECE", "HUNGARY",
"IRELAND", "ISRAEL", "ITALY", "KAZAKHSTAN", "LATVIA", "LITHUANIA", "MOROCCO",
"NETHERLANDS", "NIGERIA", "NORWAY", "PAKISTAN", "POLAND", "PORTUGAL",
"ROMANIA", "RUSSIA", "SAUDI ARABIAN", "SERBIA", "SLOVENIA", "SO.AFRICE",
"SPAIN", "SWEDEN", "SWITZERLAND", "TURKEY", "UAE", "UK", "UKRAINE",
"UZBEKISTAN")
Me.ComboBox1.ListIndex = 0
Me.ComboBox1.SetFocus
Me.ComboBox1.SelStart = 0
Me.ComboBox1.SelLength = Len(Me.ComboBox1.Text)
End Sub
Private Sub OK_Click()
ActiveDocument.FormFields("Country_Name").Result = Me.ComboBox1.Text
ActiveDocument.Bookmarks("Country_Name").Range.Fields(1).Result.Select
Unload Me
End Sub
Private Sub Reset_Click()
ActiveDocument.FormFields("Country_Name").Result = " "
ActiveDocument.Bookmarks("Country_Name").Range.Fields(1).Result.Select
Unload Me
End Sub
I've the following code in my user form currently, and it will auto prompt
the combo box to the user when they open the form. However, the country
selection field will become empty when the user open the form that they have
saved to their local drive by clicking on the "Enable Macro" button. Please
advice what should I do if I want the combo box to be shown only when the
user click on the Country_Name field and not to prompt to the user
automatically when they open the form?
My code details are as follows:
Private Sub ComboBox1_Change()
ActiveDocument.FormFields("Country_Name").Result = ComboBox1.Value
End Sub
Private Sub UserForm_Initialize()
ComboBox1.ColumnCount = 1
'Load data into ComboBox
ComboBox1.List() = Array("Please select from the list", "AUSTRIA",
"BELARUS", "BELGIUM", "BULGARIA", "CROATIA", "CZECH REPUBLIC", "DENMARK",
"EGYPT", "FINLAND", "FRANCE", "GEORGIA", "GERMANY", "GREECE", "HUNGARY",
"IRELAND", "ISRAEL", "ITALY", "KAZAKHSTAN", "LATVIA", "LITHUANIA", "MOROCCO",
"NETHERLANDS", "NIGERIA", "NORWAY", "PAKISTAN", "POLAND", "PORTUGAL",
"ROMANIA", "RUSSIA", "SAUDI ARABIAN", "SERBIA", "SLOVENIA", "SO.AFRICE",
"SPAIN", "SWEDEN", "SWITZERLAND", "TURKEY", "UAE", "UK", "UKRAINE",
"UZBEKISTAN")
Me.ComboBox1.ListIndex = 0
Me.ComboBox1.SetFocus
Me.ComboBox1.SelStart = 0
Me.ComboBox1.SelLength = Len(Me.ComboBox1.Text)
End Sub
Private Sub OK_Click()
ActiveDocument.FormFields("Country_Name").Result = Me.ComboBox1.Text
ActiveDocument.Bookmarks("Country_Name").Range.Fields(1).Result.Select
Unload Me
End Sub
Private Sub Reset_Click()
ActiveDocument.FormFields("Country_Name").Result = " "
ActiveDocument.Bookmarks("Country_Name").Range.Fields(1).Result.Select
Unload Me
End Sub