#1   Report Post  
Posted to microsoft.public.word.docmanagement
ah ah is offline
external usenet poster
 
Posts: 43
Default User Form issue

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.Fie lds(1).Result.Select
Unload Me
End Sub

Private Sub Reset_Click()

ActiveDocument.FormFields("Country_Name").Result = " "
ActiveDocument.Bookmarks("Country_Name").Range.Fie lds(1).Result.Select
Unload Me
End Sub

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default User Form issue

Call the macro that displays the userform on entry to the Country_Name
field.

See http://gregmaxey.mvps.org/FormField_...rm_ListBox.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"ah" wrote in message
...
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.Fie lds(1).Result.Select
Unload Me
End Sub

Private Sub Reset_Click()

ActiveDocument.FormFields("Country_Name").Result = " "
ActiveDocument.Bookmarks("Country_Name").Range.Fie lds(1).Result.Select
Unload Me
End Sub



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
ah ah is offline
external usenet poster
 
Posts: 43
Default User Form issue

Hi;
Thanks for your reply. However, I'm totally new to the coding.Appreciate if
you could help to identify what are the coding that I need to add to the
below so that the combo list will only prompt out to me when I click on the
Country_Name field, and not open automatically when I open the form. My code
are as follows:

User Form coding:
-------------
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.Fie lds(1).Result.Select
Unload Me
End Sub

Private Sub Reset_Click()

ActiveDocument.FormFields("Country_Name").Result = " "
ActiveDocument.Bookmarks("Country_Name").Range.Fie lds(1).Result.Select
Unload Me
End Sub

Project Module coding
----------------------------
Sub gocombobox()
UserForm.Show
End Sub





  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default User Form issue

If it is opening immediately when you open the document, you must have an
autoopen() macro some where that is calling the form. If it is not in the
template for your form, it may be in an add-in, a template that you have
saved in the Word Startup folder.

To get it to appear when you enter the Country_Name field, you need to
access the properties dialog for that field and in the Run Macro On Entry
control, select your gocombobox macro.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"ah" wrote in message
...
Hi;
Thanks for your reply. However, I'm totally new to the coding.Appreciate
if
you could help to identify what are the coding that I need to add to the
below so that the combo list will only prompt out to me when I click on
the
Country_Name field, and not open automatically when I open the form. My
code
are as follows:

User Form coding:
-------------
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.Fie lds(1).Result.Select
Unload Me
End Sub

Private Sub Reset_Click()

ActiveDocument.FormFields("Country_Name").Result = " "
ActiveDocument.Bookmarks("Country_Name").Range.Fie lds(1).Result.Select
Unload Me
End Sub

Project Module coding
----------------------------
Sub gocombobox()
UserForm.Show
End Sub







  #5   Report Post  
Posted to microsoft.public.word.docmanagement
ah ah is offline
external usenet poster
 
Posts: 43
Default User Form issue

Hi;

Thanks for your prompt response. I've selected the gocombobox macro as the
entry macro for the Country_Name field. However, when I open the form, the
country selection combo list will be prompted to me automatically. How am I
going to prevent if from prompting the country selection combo list to me?
The selection should only be prompted when i click on the Country_Name field.

Note: For your infofrmation, the Country_Name field is the 1st field in the
form.

Thanks in advance

Whe

"Doug Robbins - Word MVP" wrote:

If it is opening immediately when you open the document, you must have an
autoopen() macro some where that is calling the form. If it is not in the
template for your form, it may be in an add-in, a template that you have
saved in the Word Startup folder.

To get it to appear when you enter the Country_Name field, you need to
access the properties dialog for that field and in the Run Macro On Entry
control, select your gocombobox macro.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"ah" wrote in message
...
Hi;
Thanks for your reply. However, I'm totally new to the coding.Appreciate
if
you could help to identify what are the coding that I need to add to the
below so that the combo list will only prompt out to me when I click on
the
Country_Name field, and not open automatically when I open the form. My
code
are as follows:

User Form coding:
-------------
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.Fie lds(1).Result.Select
Unload Me
End Sub

Private Sub Reset_Click()

ActiveDocument.FormFields("Country_Name").Result = " "
ActiveDocument.Bookmarks("Country_Name").Range.Fie lds(1).Result.Select
Unload Me
End Sub

Project Module coding
----------------------------
Sub gocombobox()
UserForm.Show
End Sub










  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default User Form issue

If its the first field in the form then I would expect that selection of the
country would be the first thing to be done. If it is not, you will need to
modify the document so that it is not the first field.

However, it might really be best if you just used a userform to start with
rather than a protected document using formfields.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"ah" wrote in message
...
Hi;

Thanks for your prompt response. I've selected the gocombobox macro as the
entry macro for the Country_Name field. However, when I open the form, the
country selection combo list will be prompted to me automatically. How am
I
going to prevent if from prompting the country selection combo list to me?
The selection should only be prompted when i click on the Country_Name
field.

Note: For your infofrmation, the Country_Name field is the 1st field in
the
form.

Thanks in advance

Whe

"Doug Robbins - Word MVP" wrote:

If it is opening immediately when you open the document, you must have an
autoopen() macro some where that is calling the form. If it is not in
the
template for your form, it may be in an add-in, a template that you have
saved in the Word Startup folder.

To get it to appear when you enter the Country_Name field, you need to
access the properties dialog for that field and in the Run Macro On Entry
control, select your gocombobox macro.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"ah" wrote in message
...
Hi;
Thanks for your reply. However, I'm totally new to the
coding.Appreciate
if
you could help to identify what are the coding that I need to add to
the
below so that the combo list will only prompt out to me when I click on
the
Country_Name field, and not open automatically when I open the form. My
code
are as follows:

User Form coding:
-------------
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.Fie lds(1).Result.Select
Unload Me
End Sub

Private Sub Reset_Click()

ActiveDocument.FormFields("Country_Name").Result = " "
ActiveDocument.Bookmarks("Country_Name").Range.Fie lds(1).Result.Select
Unload Me
End Sub

Project Module coding
----------------------------
Sub gocombobox()
UserForm.Show
End Sub










Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
User Form Problems Kenny Microsoft Word Help 4 September 23rd 07 10:00 PM
Formatting Issue in Form Text Field dleepoff Microsoft Word Help 0 May 31st 06 09:39 PM
User form Mark Microsoft Word Help 1 April 9th 06 05:06 PM
Attempting to disable all user functionality in a form except for form entry [email protected] Microsoft Word Help 1 February 6th 06 04:37 PM
Text Form Field Formating Issue. Maxwell Microsoft Word Help 6 April 25th 05 08:23 PM


All times are GMT +1. The time now is 06:38 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"