Jean-Guy
Thu Oct 27 14:18:32 CDT 2005
Jean-Guy Marcil was telling us:
Jean-Guy Marcil nous racontait que :
> Miked was telling us:
> Miked nous racontait que :
>
>> I'd like to be able to add 2 drop downs to 2 cells of a table in
>> word, but I'd like to do it programmatically. I'd like to be able
>> to do this off of the add-row event in word (the event that adds a
>> table row); Is this possible, and if so, can you provide direction?
>>
>> Thank you very much in advance!
>
> If you mean ActiveX ComboBoxes, then try this code:
>
> Dim TargetTable As Table
> Dim myCtrl As InlineShape
>
> Set TargetTable = ActiveDocument.Tables(1)
>
> With TargetTable
> .Rows.Add
>
> With .Rows(TargetTable.Rows.Count - 1)
> Set myCtrl = .Cells(1).Range.InlineShapes.AddOLEControl _
> (ClassType:="Forms.ComboBox.1")
> With myCtrl.OLEFormat.Object
> .Style = 2 ' fmStyleDropDownList
> .AddItem "123"
> .AddItem "456"
> .AddItem "789"
> .AddItem "012"
> End With
>
> Set myCtrl = .Cells(2).Range.InlineShapes.AddOLEControl _
> (ClassType:="Forms.ComboBox.1")
> With myCtrl.OLEFormat.Object
> .Style = 2 ' fmStyleDropDownList
> .AddItem "abc"
> .AddItem "def"
> .AddItem "ghi"
> .AddItem "jkl"
> End With
>
> End With
>
> End With
Ooops... remove the "- 1" in the line
With .Rows(TargetTable.Rows.Count - 1)
so that it looks like:
With .Rows(TargetTable.Rows.Count)
Sorry about that.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site:
http://www.word.mvps.org