Using VBA, Add data to the combo box list upon creation of the obj

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Powerpoint with Office 2003

Is this possible. I've combed the net and MSDN and all instances of
populating a combo box list seem to work only when you manually "Edit" the
shape after creating it. When attempting to do it through the vba code that
is creating the combo box, I can't get it to work.

I've tried variations of creating the box. This, below, is my last one. I
can't find a way for the code to recognize the additem method. I only had
luck manually entering it into the code change event for the newly created
combo box.

I guess the question might be, can you, with VBA, create a sub procedure
when creating the combo box?
*******************
Public Sub AddPPTComboBox(app As PowerPoint.Application, dblLeft As Double,
dbltop As Double, dblWidth As Double, dblheight As Double, strname As String)
On Error GoTo errhandler

Dim shp As Object
Set shp =
app.ActiveWindow.Selection.SlideRange.Shapes.AddOLEObject(Left:=dblLeft, _
Top:=dbltop, Width:=dblWidth, Height:=dblheight,
ClassName:="Forms.ComboBox.1", Link:=msoFalse)

Exit Sub
errhandler:
MsgBox Err.Number & ": " & Err.Description, , "AddPPTComboBox"
End Sub
***************************



Matthew Mark
 
Matthewmark said:
Powerpoint with Office 2003

Is this possible. I've combed the net and MSDN and all instances of
populating a combo box list seem to work only when you manually "Edit" the
shape after creating it. When attempting to do it through the vba code that
is creating the combo box, I can't get it to work.

I've tried variations of creating the box. This, below, is my last one. I
can't find a way for the code to recognize the additem method. I only had
luck manually entering it into the code change event for the newly created
combo box.

I guess the question might be, can you, with VBA, create a sub procedure
when creating the combo box?
*******************
Public Sub AddPPTComboBox(app As PowerPoint.Application, dblLeft As Double,
dbltop As Double, dblWidth As Double, dblheight As Double, strname As String)
On Error GoTo errhandler

Dim shp As Object
Set shp =
app.ActiveWindow.Selection.SlideRange.Shapes.AddOLEObject(Left:=dblLeft, _
Top:=dbltop, Width:=dblWidth, Height:=dblheight,
ClassName:="Forms.ComboBox.1", Link:=msoFalse)

Exit Sub
errhandler:
MsgBox Err.Number & ": " & Err.Description, , "AddPPTComboBox"
End Sub
***************************

Matthew Mark

Easier, perhaps, if you Dim shp as Shape, but not necessary.

Having created shp you can:

With shp.OLEFormat.Object
' do anything you'd normally do with
' combobox properties/methods on a form
.AddItem("This")
.AddItem("That")
.AddItem("The other")
End with
 
Back
Top