A
Archie Dog via OfficeKB.com
I have created a custom toolbar with two drop down boxes.
The drop down boxes were initially created on the toolbar using code.
***********
Dim cmdB As CommandBar
Dim newButton As CommandBarButton
‘strUDTBar is a Public Constant containing the name of the toolbar as a
string
Set cmdB = Application.CommandBars(strUDTbar)
With cmdB
.Visible = True
With .Controls.Add(msoControlComboBox)
.Move cmdB, 4
.Width = intTBBranchWidth
.Caption = "Office"
.BeginGroup = True
.OnAction = "Populate_Employees"
End With
End With
***********
Subsequently, the system does not re-create the toolbar drop down boxes but
clears & re-populates them.
The first combo box contains a list of offices. This is re-populated every
time Word is loaded.
The office names are put into an array (declared as a Public variable as it
is used by a number of procedures) when the drop down list is created. The
contents of this array are then erased.
When the user selects an item in the first combo box, the second box is
populated with the names of employees in the selected office. Again, the
employee names are in a Public array and this is erased once the drop down
list has been populated.
The template containing the relevant code is in Startup & therefore loaded
when Word is first started. It is the only template loaded.
This all seems to work fine, as long as I don’t create a new document! The
‘New’ command is the standard MS Word one.
When I create a new document, the selected office remains correct. However,
the employee may either be blank and, if this occurs, there are no names in
the employee drop down list. Alternatively, the drop down box may pick up a
list of employees from a completely different branch.
If I go back to my original document, the values are correct. The results
can vary each time I create a new document.
I have put a break point in every single procedure to see if something is
inadvertedly kicking off code somewhere but it is not running any code when
it goes wrong.
I’m sure I’m missing something simple here but I’m darned if I can see what
it is.
I haven’t posted all the code as there is rather a lot of it. Do I I need to
supply more info?
Am at my wit's end! Any help very, very gratefully appreciated.
ArchieD
The drop down boxes were initially created on the toolbar using code.
***********
Dim cmdB As CommandBar
Dim newButton As CommandBarButton
‘strUDTBar is a Public Constant containing the name of the toolbar as a
string
Set cmdB = Application.CommandBars(strUDTbar)
With cmdB
.Visible = True
With .Controls.Add(msoControlComboBox)
.Move cmdB, 4
.Width = intTBBranchWidth
.Caption = "Office"
.BeginGroup = True
.OnAction = "Populate_Employees"
End With
End With
***********
Subsequently, the system does not re-create the toolbar drop down boxes but
clears & re-populates them.
The first combo box contains a list of offices. This is re-populated every
time Word is loaded.
The office names are put into an array (declared as a Public variable as it
is used by a number of procedures) when the drop down list is created. The
contents of this array are then erased.
When the user selects an item in the first combo box, the second box is
populated with the names of employees in the selected office. Again, the
employee names are in a Public array and this is erased once the drop down
list has been populated.
The template containing the relevant code is in Startup & therefore loaded
when Word is first started. It is the only template loaded.
This all seems to work fine, as long as I don’t create a new document! The
‘New’ command is the standard MS Word one.
When I create a new document, the selected office remains correct. However,
the employee may either be blank and, if this occurs, there are no names in
the employee drop down list. Alternatively, the drop down box may pick up a
list of employees from a completely different branch.
If I go back to my original document, the values are correct. The results
can vary each time I create a new document.
I have put a break point in every single procedure to see if something is
inadvertedly kicking off code somewhere but it is not running any code when
it goes wrong.
I’m sure I’m missing something simple here but I’m darned if I can see what
it is.
I haven’t posted all the code as there is rather a lot of it. Do I I need to
supply more info?
Am at my wit's end! Any help very, very gratefully appreciated.
ArchieD