|
用Visual Studio在工作表建立ComboBox,可以建立對象,但無法添加項目。請高手協助。謝謝!
Imports Microsoft.Office.Interop.Excel
Dim xlApp As Object = GetObject(, "Excel.Application")
Dim Combo1 As OLEObject
With xlApp.activeworkbook.ActiveSheet
Combo1 = .OLEObjects.Add(ClassType:="Forms.ComboBox.1", Left:=.Range("A2").left, Top:=.Range("A2").top, Width:=.Range("A2").width, Height:=.range("A3").top - .range("A2").top)
'欲添加項目,但試了以下幾個方法都不行
'Combo1.listfillrange = "C3:C6"
'DirectCast(Combo1, OLEFormat).listfillrange = "C3:C6"
'DirectCast(Combo1, OLEFormat).Object.listfillrange = "C3:C6"
'DirectCast(Combo1, OLEFormat).Items.Add "項目一"
'DirectCast(Combo1, OLEFormat).Object.Items.Add "項目一"
End With
|
|