Discussion:
InlineShapes
(too old to reply)
Ambiga
2008-02-29 11:32:10 UTC
Permalink
Hi,

I want to know how to retrieve the list items of List Box and combo Box
controls available in Inlineshapes.

Thanks in advance.

-----
Ambiga
fumei via OfficeKB.com
2008-02-29 20:52:31 UTC
Permalink
Loads up a Listbox and a Combobox

Sub LoadEmUp()
Dim whatever1()
Dim whatever2()
Dim var, var2
whatever1 = Array("LIST_item1", "LIST_item2", "LIST_item3")

whatever2 = Array("COMBO_item1", "COMBO_item2", _
"COMBO_item3", "COMBO_item4", "COMBO_item5")

ListBox1.Clear
ComboBox1.Clear
For var = 0 To UBound(whatever1)
ListBox1.AddItem whatever1(var)
Next

For var2 = 0 To UBound(whatever2)
ComboBox1.AddItem whatever2(var2)
Next

ComboBox1.ListIndex = 0
End Sub


Gets the lists

Sub GetEm()
Dim msg As String
Dim myObject As Object
Dim objInline As InlineShape
Dim var, var2
If ActiveDocument.InlineShapes.Count > 0 Then
For var = 1 To ActiveDocument.InlineShapes.Count
Set objInline = ActiveDocument.InlineShapes.Item(var)
If objInline.Type = 5 Then
For var2 = 0 To objInline.OLEFormat.Object.ListCount - 1
MsgBox objInline.OLEFormat.Object.List(var2)
Next
End If
Next
End If
End Sub

The reason the code checks for Type, is in case there is an InlineShape that
is NOT a wdInlineShapeOLEControlObject (type = 5)

You may need to go deeper with this if you have control objects that are not
either listbox or combobox.

You could use a TypeOf check.

However, I question why you are doing this as you have to populate the list
anyway, to get the list in there. So....you should have the list already.

or are you asking really for something else?
Post by Ambiga
Hi,
I want to know how to retrieve the list items of List Box and combo Box
controls available in Inlineshapes.
Thanks in advance.
-----
Ambiga
--
Message posted via http://www.officekb.com
fumei via OfficeKB.com
2008-02-29 20:53:42 UTC
Permalink
Oh crap. I was going to use a msg string to build the list into ONE message..
.but then forgot to use it.
Post by fumei via OfficeKB.com
Loads up a Listbox and a Combobox
Sub LoadEmUp()
Dim whatever1()
Dim whatever2()
Dim var, var2
whatever1 = Array("LIST_item1", "LIST_item2", "LIST_item3")
whatever2 = Array("COMBO_item1", "COMBO_item2", _
"COMBO_item3", "COMBO_item4", "COMBO_item5")
ListBox1.Clear
ComboBox1.Clear
For var = 0 To UBound(whatever1)
ListBox1.AddItem whatever1(var)
Next
For var2 = 0 To UBound(whatever2)
ComboBox1.AddItem whatever2(var2)
Next
ComboBox1.ListIndex = 0
End Sub
Gets the lists
Sub GetEm()
Dim msg As String
Dim myObject As Object
Dim objInline As InlineShape
Dim var, var2
If ActiveDocument.InlineShapes.Count > 0 Then
For var = 1 To ActiveDocument.InlineShapes.Count
Set objInline = ActiveDocument.InlineShapes.Item(var)
If objInline.Type = 5 Then
For var2 = 0 To objInline.OLEFormat.Object.ListCount - 1
MsgBox objInline.OLEFormat.Object.List(var2)
Next
End If
Next
End If
End Sub
The reason the code checks for Type, is in case there is an InlineShape that
is NOT a wdInlineShapeOLEControlObject (type = 5)
You may need to go deeper with this if you have control objects that are not
either listbox or combobox.
You could use a TypeOf check.
However, I question why you are doing this as you have to populate the list
anyway, to get the list in there. So....you should have the list already.
or are you asking really for something else?
Post by Ambiga
Hi,
[quoted text clipped - 5 lines]
Post by Ambiga
-----
Ambiga
--
Message posted via http://www.officekb.com
Ambiga
2008-03-04 12:07:00 UTC
Permalink
Thank for your replies, and that solved the problem.

---
Ambiga
Post by fumei via OfficeKB.com
Oh crap. I was going to use a msg string to build the list into ONE message..
.but then forgot to use it.
Post by fumei via OfficeKB.com
Loads up a Listbox and a Combobox
Sub LoadEmUp()
Dim whatever1()
Dim whatever2()
Dim var, var2
whatever1 = Array("LIST_item1", "LIST_item2", "LIST_item3")
whatever2 = Array("COMBO_item1", "COMBO_item2", _
"COMBO_item3", "COMBO_item4", "COMBO_item5")
ListBox1.Clear
ComboBox1.Clear
For var = 0 To UBound(whatever1)
ListBox1.AddItem whatever1(var)
Next
For var2 = 0 To UBound(whatever2)
ComboBox1.AddItem whatever2(var2)
Next
ComboBox1.ListIndex = 0
End Sub
Gets the lists
Sub GetEm()
Dim msg As String
Dim myObject As Object
Dim objInline As InlineShape
Dim var, var2
If ActiveDocument.InlineShapes.Count > 0 Then
For var = 1 To ActiveDocument.InlineShapes.Count
Set objInline = ActiveDocument.InlineShapes.Item(var)
If objInline.Type = 5 Then
For var2 = 0 To objInline.OLEFormat.Object.ListCount - 1
MsgBox objInline.OLEFormat.Object.List(var2)
Next
End If
Next
End If
End Sub
The reason the code checks for Type, is in case there is an InlineShape that
is NOT a wdInlineShapeOLEControlObject (type = 5)
You may need to go deeper with this if you have control objects that are not
either listbox or combobox.
You could use a TypeOf check.
However, I question why you are doing this as you have to populate the list
anyway, to get the list in there. So....you should have the list already.
or are you asking really for something else?
Post by Ambiga
Hi,
[quoted text clipped - 5 lines]
Post by Ambiga
-----
Ambiga
--
Message posted via http://www.officekb.com
Loading...