Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Scott
 
Posts: n/a
Default ComboBox and UserForm_Initialize

I am trying to implement a comboBox using the controls menu. I have writtem a
UserForm_Initialize routine but it seems not to execute. When I click on the
drop down all I get is a blank dropdown space with the down arrow. The drop
down menu is not populated (initialized), However if I use the debugger to
step through the UserForm_Initialze routine all works fine the comboBox is
populated and I can make different selections. What gives? When/How is the
UserForm_Initialize routine executed? How can I force the routine to be
executed ? Or is there something else I need to do?

-Thanks in advance
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP
 
Posts: n/a
Default ComboBox and UserForm_Initialize

How are you calling the UserForm?

Is it really a UserForm or have you inserted controls directly into the
document from the ViewToolbarsControl Toolbox?

--
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

"Scott" wrote in message
...
I am trying to implement a comboBox using the controls menu. I have writtem
a
UserForm_Initialize routine but it seems not to execute. When I click on
the
drop down all I get is a blank dropdown space with the down arrow. The
drop
down menu is not populated (initialized), However if I use the debugger to
step through the UserForm_Initialze routine all works fine the comboBox is
populated and I can make different selections. What gives? When/How is the
UserForm_Initialize routine executed? How can I force the routine to be
executed ? Or is there something else I need to do?

-Thanks in advance



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Scott
 
Posts: n/a
Default ComboBox and UserForm_Initialize

I used the ViewToolbarsControl Toolbox. After adding the ComboBox I right
clicked , then view code. Which placed me into Visual Basic. I added the
UserForm_Initialize code as shown in the VBA help example.

Which contains:

Private Sub UserForm_Initialize ()

ComboBox1.AddItem "Above Left"
ComboBox1.AddItem "Above Center"
ComboBox1.AddItem "Above Right"
ComboBox1.AddItem "Below Left"
ComboBox1.AddItem "Below Center"
ComboBox1.AddItem "Below Right"
ComboBox1.AddItem "Centered"

'Use drop-down list
ComboBox1.Style = fmStyleDropDownCombo

'Combo box values are ListIndex values
ComboBox1.BoundColumn = 0

'Set combo box to first entry
ComboBox1.ListIndex = 0
End Sub



I also added the ComboBox1_Change and _Click code into the same window
(titled the same name as my word doc - This Document). The _Change code works
but the Dropdown List is not populated.

Should I place the Initialization code elsewhere ?

-Scott


"Doug Robbins - Word MVP" wrote:

How are you calling the UserForm?

Is it really a UserForm or have you inserted controls directly into the
document from the ViewToolbarsControl Toolbox?

--
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

"Scott" wrote in message
...
I am trying to implement a comboBox using the controls menu. I have writtem
a
UserForm_Initialize routine but it seems not to execute. When I click on
the
drop down all I get is a blank dropdown space with the down arrow. The
drop
down menu is not populated (initialized), However if I use the debugger to
step through the UserForm_Initialze routine all works fine the comboBox is
populated and I can make different selections. What gives? When/How is the
UserForm_Initialize routine executed? How can I force the routine to be
executed ? Or is there something else I need to do?

-Thanks in advance




  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP
 
Posts: n/a
Default ComboBox and UserForm_Initialize

A document in which you place a combobox from the controls menu is not a
userform. As a result, there is no userform initialize event that can be
used to populate your combobox.

While I would never use a combobox of that type in a document, if you want
to, you can get it populated by the use of code such as the following in the
This Document module

Private Sub ComboBox1_GotFocus()
Dim i As Long
For i = ComboBox1.ListCount - 1 To 0 Step -1
ComboBox1.RemoveItem (i)
Next i
ComboBox1.AddItem "Above Left"
ComboBox1.AddItem "Above Center"
ComboBox1.AddItem "Above Right"
ComboBox1.AddItem "Below Left"
ComboBox1.AddItem "Below Center"
ComboBox1.AddItem "Below Right"
ComboBox1.AddItem "Centered"
End Sub


--
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

"Scott" wrote in message
...
I used the ViewToolbarsControl Toolbox. After adding the ComboBox I
right
clicked , then view code. Which placed me into Visual Basic. I added the
UserForm_Initialize code as shown in the VBA help example.

Which contains:

Private Sub UserForm_Initialize ()

ComboBox1.AddItem "Above Left"
ComboBox1.AddItem "Above Center"
ComboBox1.AddItem "Above Right"
ComboBox1.AddItem "Below Left"
ComboBox1.AddItem "Below Center"
ComboBox1.AddItem "Below Right"
ComboBox1.AddItem "Centered"

'Use drop-down list
ComboBox1.Style = fmStyleDropDownCombo

'Combo box values are ListIndex values
ComboBox1.BoundColumn = 0

'Set combo box to first entry
ComboBox1.ListIndex = 0
End Sub



I also added the ComboBox1_Change and _Click code into the same window
(titled the same name as my word doc - This Document). The _Change code
works
but the Dropdown List is not populated.

Should I place the Initialization code elsewhere ?

-Scott


"Doug Robbins - Word MVP" wrote:

How are you calling the UserForm?

Is it really a UserForm or have you inserted controls directly into the
document from the ViewToolbarsControl Toolbox?

--
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

"Scott" wrote in message
...
I am trying to implement a comboBox using the controls menu. I have
writtem
a
UserForm_Initialize routine but it seems not to execute. When I click
on
the
drop down all I get is a blank dropdown space with the down arrow. The
drop
down menu is not populated (initialized), However if I use the debugger
to
step through the UserForm_Initialze routine all works fine the comboBox
is
populated and I can make different selections. What gives? When/How is
the
UserForm_Initialize routine executed? How can I force the routine to be
executed ? Or is there something else I need to do?

-Thanks in advance






  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Scott
 
Posts: n/a
Default ComboBox and UserForm_Initialize

Thanks for your help! I'll give that a try today!

I'm using the ComboBox because I would like to have choices of some rather
long strings to be placed into a comment area on my form. These strings are
larger than the 50 chars that are standard in the Dropdown form type. Any
other
suggestions ?

-Thanks

"Doug Robbins - Word MVP" wrote:

A document in which you place a combobox from the controls menu is not a
userform. As a result, there is no userform initialize event that can be
used to populate your combobox.

While I would never use a combobox of that type in a document, if you want
to, you can get it populated by the use of code such as the following in the
This Document module

Private Sub ComboBox1_GotFocus()
Dim i As Long
For i = ComboBox1.ListCount - 1 To 0 Step -1
ComboBox1.RemoveItem (i)
Next i
ComboBox1.AddItem "Above Left"
ComboBox1.AddItem "Above Center"
ComboBox1.AddItem "Above Right"
ComboBox1.AddItem "Below Left"
ComboBox1.AddItem "Below Center"
ComboBox1.AddItem "Below Right"
ComboBox1.AddItem "Centered"
End Sub


--
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

"Scott" wrote in message
...
I used the ViewToolbarsControl Toolbox. After adding the ComboBox I
right
clicked , then view code. Which placed me into Visual Basic. I added the
UserForm_Initialize code as shown in the VBA help example.

Which contains:

Private Sub UserForm_Initialize ()

ComboBox1.AddItem "Above Left"
ComboBox1.AddItem "Above Center"
ComboBox1.AddItem "Above Right"
ComboBox1.AddItem "Below Left"
ComboBox1.AddItem "Below Center"
ComboBox1.AddItem "Below Right"
ComboBox1.AddItem "Centered"

'Use drop-down list
ComboBox1.Style = fmStyleDropDownCombo

'Combo box values are ListIndex values
ComboBox1.BoundColumn = 0

'Set combo box to first entry
ComboBox1.ListIndex = 0
End Sub



I also added the ComboBox1_Change and _Click code into the same window
(titled the same name as my word doc - This Document). The _Change code
works
but the Dropdown List is not populated.

Should I place the Initialization code elsewhere ?

-Scott


"Doug Robbins - Word MVP" wrote:

How are you calling the UserForm?

Is it really a UserForm or have you inserted controls directly into the
document from the ViewToolbarsControl Toolbox?

--
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

"Scott" wrote in message
...
I am trying to implement a comboBox using the controls menu. I have
writtem
a
UserForm_Initialize routine but it seems not to execute. When I click
on
the
drop down all I get is a blank dropdown space with the down arrow. The
drop
down menu is not populated (initialized), However if I use the debugger
to
step through the UserForm_Initialze routine all works fine the comboBox
is
populated and I can make different selections. What gives? When/How is
the
UserForm_Initialize routine executed? How can I force the routine to be
executed ? Or is there something else I need to do?

-Thanks in advance








  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP
 
Posts: n/a
Default ComboBox and UserForm_Initialize

I would use a userform. See the article "How to create a Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.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

"Scott" wrote in message
...
Thanks for your help! I'll give that a try today!

I'm using the ComboBox because I would like to have choices of some rather
long strings to be placed into a comment area on my form. These strings
are
larger than the 50 chars that are standard in the Dropdown form type. Any
other
suggestions ?

-Thanks

"Doug Robbins - Word MVP" wrote:

A document in which you place a combobox from the controls menu is not a
userform. As a result, there is no userform initialize event that can be
used to populate your combobox.

While I would never use a combobox of that type in a document, if you
want
to, you can get it populated by the use of code such as the following in
the
This Document module

Private Sub ComboBox1_GotFocus()
Dim i As Long
For i = ComboBox1.ListCount - 1 To 0 Step -1
ComboBox1.RemoveItem (i)
Next i
ComboBox1.AddItem "Above Left"
ComboBox1.AddItem "Above Center"
ComboBox1.AddItem "Above Right"
ComboBox1.AddItem "Below Left"
ComboBox1.AddItem "Below Center"
ComboBox1.AddItem "Below Right"
ComboBox1.AddItem "Centered"
End Sub


--
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

"Scott" wrote in message
...
I used the ViewToolbarsControl Toolbox. After adding the ComboBox I
right
clicked , then view code. Which placed me into Visual Basic. I added
the
UserForm_Initialize code as shown in the VBA help example.

Which contains:

Private Sub UserForm_Initialize ()

ComboBox1.AddItem "Above Left"
ComboBox1.AddItem "Above Center"
ComboBox1.AddItem "Above Right"
ComboBox1.AddItem "Below Left"
ComboBox1.AddItem "Below Center"
ComboBox1.AddItem "Below Right"
ComboBox1.AddItem "Centered"

'Use drop-down list
ComboBox1.Style = fmStyleDropDownCombo

'Combo box values are ListIndex values
ComboBox1.BoundColumn = 0

'Set combo box to first entry
ComboBox1.ListIndex = 0
End Sub



I also added the ComboBox1_Change and _Click code into the same window
(titled the same name as my word doc - This Document). The _Change code
works
but the Dropdown List is not populated.

Should I place the Initialization code elsewhere ?

-Scott


"Doug Robbins - Word MVP" wrote:

How are you calling the UserForm?

Is it really a UserForm or have you inserted controls directly into
the
document from the ViewToolbarsControl Toolbox?

--
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

"Scott" wrote in message
...
I am trying to implement a comboBox using the controls menu. I have
writtem
a
UserForm_Initialize routine but it seems not to execute. When I
click
on
the
drop down all I get is a blank dropdown space with the down arrow.
The
drop
down menu is not populated (initialized), However if I use the
debugger
to
step through the UserForm_Initialze routine all works fine the
comboBox
is
populated and I can make different selections. What gives? When/How
is
the
UserForm_Initialize routine executed? How can I force the routine to
be
executed ? Or is there something else I need to do?

-Thanks in advance








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
Word toolbar styles and formatting combobox should be wider Opa Microsoft Word Help 1 April 19th 06 04:11 PM
How do I set up a combobox on word? omolano New Users 1 November 10th 05 05:27 AM
combobox combine with textbox hein Microsoft Word Help 1 February 14th 05 04:58 PM
Hide Combobox when printing Jose J. Ramirez Microsoft Word Help 2 January 21st 05 05:07 PM
combobox in word Vineet Gupta, MD Microsoft Word Help 2 December 17th 04 12:55 AM


All times are GMT +1. The time now is 01:54 AM.

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

About Us

"It's about Microsoft Word"