无法selectcombobox

我有一个名为“工具”的combobox已被添加为Excel 2010工作表的窗体控件。 我还有一个标题为“AdjustmentsAmount”的模块,它是通过点击一个表单button来运行下面的方法。 我已经尝试了几种访问表单控件的方法,而且都没有工作,下面也列出了。 任何人都可以阐明这个问题吗?

'Clears all run specifications Sub clearRunSpecs_click() Dim resp As String resp = MsgBox("This will clear all run specifications. Are you sure you want to continue?", vbYesNo) If (resp = vbYes) Then Worksheets("AdjustmentsAmount").Unprotect "pass" Range("D3").Clear Range("D3").Interior.Color = RGB(235, 241, 222) Range("D3").BorderAround LineStyle:=XlLineStyle.xlContinuous, Weight:=xlMedium, ColorIndex:=xlColorIndexAutomatic, Color:=RGB(0, 0, 0) Range("D3").Locked = False Range("D4").Clear Range("D4").Interior.Color = RGB(235, 241, 222) Range("D4").BorderAround LineStyle:=XlLineStyle.xlContinuous, Weight:=xlMedium, ColorIndex:=xlColorIndexAutomatic, Color:=RGB(0, 0, 0) Range("D4").Locked = False Range("B4").Clear Range("B4").Interior.Color = RGB(235, 241, 222) Range("B4").BorderAround LineStyle:=XlLineStyle.xlContinuous, Weight:=xlMedium, ColorIndex:=xlColorIndexAutomatic, Color:=RGB(0, 0, 0) Range("B4").Locked = False Range("A17:D22").Clear Range("A17:D22").Merge Range("A17:D22").Interior.Color = RGB(235, 241, 222) Range("A17:D22").BorderAround LineStyle:=XlLineStyle.xlContinuous, Weight:=xlMedium, ColorIndex:=xlColorIndexAutomatic, Color:=RGB(0, 0, 0) Range("A17:D22").VerticalAlignment = xlTop Range("A17:D22").Locked = False ActiveSheet.Shapes("Facility").ListIndex = -1 ActiveSheet.CheckBoxes("ZeroBalance").Value = xlOff ActiveSheet.CheckBoxes("Balance<Adj").Value = xlOff ActiveSheet.CheckBoxes("Balance=Adj").Value = xlOff Worksheets("AdjustmentsAmount").Protect "pass" End If End Sub 

方法尝试

 ActiveSheet.Shapes("Facility") ActiveSheet.Facility ActiveSheet.ListBoxes("Facility") Application.Facility 

我已经使用ActiveSheet.CheckBoxes("NAME")在相同的方法访问checkbox,工作正常。 但是,我似乎无法获取combobox的位置。

我已经设置了一个空行来ListIndex1和使用:

 ActiveSheet.Shapes("Facility").ControlFormat.ListIndex = 1 

访问它。 我假设这就是你需要的?

这是有点隐藏 – 你可以像这样访问列表框或combobox:

 Debug.Print ActiveSheet.Shapes("Facility").OLEFormat.Object.Value