我有一個名爲「工具」的組合框已被添加爲Excel 2010工作表的窗體控件。我還有一個標題爲「AdjustmentsAmount」的模塊,它可以通過點擊表單按鈕來運行下面的方法。我已經嘗試了幾種訪問表單控件的方法,但都沒有工作,下面也列出了。任何人都可以闡明這個問題嗎?無法選擇組合框
代碼
'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")
同樣的方法訪問複選框,並且工作得很好。但是,我似乎無法獲取組合框的位置。
我希望框重置爲空狀態。我認爲這是listindex = -1(正如我之前在網站上看到的,現在我無法回想),但這是不允許的。有什麼想法嗎? – steventnorris 2013-03-19 12:56:45
ListIndex = 0有效 – steventnorris 2013-03-19 12:59:01