Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取按标签分组的spinbutton的值(Excel 2007)_Excel_Shapes_Vba - Fatal编程技术网

获取按标签分组的spinbutton的值(Excel 2007)

获取按标签分组的spinbutton的值(Excel 2007),excel,shapes,vba,Excel,Shapes,Vba,我正在设计一个交互式模式,文本框与连接器相连,旋转按钮指示连接器的“强度”。现在我只想获取元素的名称、值和连接,以备将来使用。我的问题是,我用一个标签将每个spinbutton分组(这样在我未来的代码中我就可以显示spinbutton的值),而在下面的代码中,我无法获得spinbutton的值。我尝试了各种方法,比如subshp.OLEFormat.Object.Value,但都没有成功 我正在粘贴上下文的完整代码,但我的问题在于shMyShape.GroupItems中每个子HP的之后的代码。

我正在设计一个交互式模式,文本框与连接器相连,旋转按钮指示连接器的“强度”。现在我只想获取元素的名称、值和连接,以备将来使用。我的问题是,我用一个标签将每个spinbutton分组(这样在我未来的代码中我就可以显示spinbutton的值),而在下面的代码中,我无法获得spinbutton的值。我尝试了各种方法,比如
subshp.OLEFormat.Object.Value
,但都没有成功

我正在粘贴上下文的完整代码,但我的问题在于shMyShape.GroupItems中每个子HP的
之后的代码。谢谢

Private Sub CB1_Click()
    Dim shMyShape, subshp As Shape
    Dim i As Long
    Dim theSubShapes as String

    Worksheets("MySchema").Range("A1:M100").ClearContents
    i = 1
    For Each shMyShape In Worksheets("MySchema").Shapes

        If (shMyShape.Connector) Then
            Worksheets("MySchema").Cells(i, 1) = "Shape name: "
            Worksheets("MySchema").Cells(i, 2) = shMyShape.Name
            Worksheets("MySchema").Cells(i, 3) = "Connector. Comes from " & shMyShape.ConnectorFormat.BeginConnectedShape.TextFrame.Characters.Text & " and goes to " & shMyShape.ConnectorFormat.EndConnectedShape.TextFrame.Characters.Text
            i = i + 1
        End If
        If (shMyShape.Type = msoTextBox) Then
            Worksheets("MySchema").Cells(i, 1) = "Shape name: "
            Worksheets("MySchema").Cells(i, 2) = shMyShape.Name
            Worksheets("MySchema").Cells(i, 3) = "Textbox, and its value is: " & shMyShape.TextFrame.Characters.Text
            i = i + 1
        End If
        If (shMyShape.Type = msoGroup) Then
            Worksheets("MySchema").Cells(i, 1) = "Shape name: "
            Worksheets("MySchema").Cells(i, 2) = shMyShape.Name
                theSubShapes = ""

                'here starts my problem
                For Each subshp In shMyShape.GroupItems
                    theSubShapes = theSubShapes & "-" & subshp.Name & "/" 'Here I need to get the spinbutton value (e.g., subshp.Value or subshp.OLEFormat.Object.Value)
                Next subshp
                Worksheets("MySchema").Cells(i, 3) = theSubShapes
            i = i + 1
        End If
    Next
End Sub

这是一个愚蠢的问题,但您是否尝试过:

 subshp.Value 'instead of subshp.Values

是的,这只是问题中的一个输入错误。现在编辑。谢谢你的提问。如果有人到了这里,最终的解决方案是
subshp.OLEFormat.Object.Object.Value
。在我的案例中,这不是一种合乎逻辑的方法,只是尝试和错误:(