我設計的互動模式,與連接器連接的文本框,並spinbuttons指示的連接器的「實力」。現在我只想獲取元素的名稱,值和連接以備將來使用。我的問題是,我有一個標籤分組(讓我在以後的代碼,我就可以顯示數值調節鈕值),並在下面的代碼我無法得到數值調節鈕的值的每個數值調節鈕。我嘗試了各種各樣的東西,如subshp.OLEFormat.Object.Value
沒有成功。獲得價值(Excel 2007中)
我粘貼上下文的全部代碼,但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
解決。萬一有人送過來,最後的解決辦法是'subshp.OLEFormat.Object.Object.Value'。不是在我的情況下,合理的方法,但只是試錯:( – CMArg