Excel-VBA: Getting the values from Form Controls

后端 未结 6 1783
挽巷
挽巷 2020-12-19 00:22

Embedded in the worksheet sheet1 I have a Form Control combo box named combobox_test and it has selected value x

in addition t

6条回答
  •  孤城傲影
    2020-12-19 01:01

    As said before the Shape ComboBox has no Value property.

    I use the DrawingObject property of the Shape object to get a CheckBox FormControl object. This CheckBox object can then be used like any other FormControl.

    You should also be able to use the DrawinObject to get the ComboBox objcet form the Shape object.

    If you want to get te selected text then you can try following code snipped:

    Dim sh as Shape
    Dim cB as ComboBox
    For Each sh In ws.Shapes
        If sh.Type = msoFormControl Then
            If TypeOf sh.DrawingObject Is ComboBox Then
                Set cB = sh.DrawingObject
                ... 
                your code for getting the Data from ComboBox
                ...
            End If
        End If
    Next
    

提交回复
热议问题