Combo Box

O

Owen

Hi All...i was wondering if any gurus out there might be able to help with
the problem below?

I have a Word 2003 document which contains a table. I have recorded a command
button Macro which enables the user to copy the last row of a table and paste
it as a new row below.

The copied row contains a combobox list which has about 300 entries within
the combobox. When the macro creates a new row in the table, it copies the
shell of the combobox but does not copy the 300 entries. As a result, when
the new combobox list is clicked, there are no entries in the drop down.

Is it possible to include some coding to also copy the contents of the
combobox list?

Appreciate any help that can be provided.

Best Regards
Owen
 
D

Doug Robbins - Word MVP

Use VBA to set the .List property of the new combobox to the .List property
of the old combobox.

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

Owen

Hi Doug

Should the coding look like this? I am new to VBA so ned a few tips.

Also, would there be a way to enable the .List property to automatically be
assigned to all new combo boxes that are created?

Private Sub ComboBox1129_Click()
With ComboBox1129
..List = ComboBox1.List
End With
End Sub

Thanks again
 
G

Greg Maxey

Hi Doug

Should the coding look like this? I am new to VBA so ned a few tips.

Also, would there be a way to enable the .List property to automatically be
assigned to all new combo boxes that are created?

Private Sub ComboBox1129_Click()
With ComboBox1129
.List = ComboBox1.List
End With
End Sub

Thanks again

:






- Show quoted text -

Owen,

Code assumes the master cb is in row 1 column 4


Sub AddNewRow()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Tables(1).Rows.Last.Range
oRng.MoveEnd wdCharacter, -2
oRng.Select
Selection.Copy
Selection.InsertRowsBelow 1
Selection.Paste
PopulateNewCB
End Sub
Sub PopulateNewCB()
Dim oTbl As Word.Table
Dim oCtrMaster As Object
Dim oCtrSlave As Object
Set oTbl = ActiveDocument.Tables(1)
'Assumes MasterCB is in row 1 column 4
Set oCtrMaster = oTbl.Cell(1, 4).Range.InlineShapes
(1).OLEFormat.Object
Set oCtrSlave = oTbl.Cell(oTbl.Rows.Count, 4).Range.InlineShapes
(1).OLEFormat.Object
oCtrSlave.List = oCtrMaster.List
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top