我正在设计一个交互式架构,其中TextBoxes与连接器连接,而旋转按钮则指示"强度"连接器。现在我只想获取元素的名称,值和连接以供将来使用。我的问题是我将每个旋转按钮与一个标签组合在一起(以便在我将来的代码中我能够显示旋钮的值),并且在下面的代码中我无法获得旋钮的值。我尝试了各种各样的事情,比如subshp.OLEFormat.Object.Value
没有成功。
我粘贴了完整的上下文代码,但我的问题出现在For Each subshp In shMyShape.GroupItems
之后的代码中。感谢。
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
答案 0 :(得分:0)
这是一个愚蠢的问题,但你试过了吗?
subshp.Value 'instead of subshp.Values