2017-05-09 72 views
0

我设计的互动模式,与连接器连接的文本框,并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 
+0

解决。万一有人送过来,最后的解决办法是'subshp.OLEFormat.Object.Object.Value'。不是在我的情况下,合理的方法,但只是试错:( – CMArg

回答

0

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

subshp.Value 'instead of subshp.Values 
+0

是的,它只是问题的拼写错误。现在编辑。谢谢aswering。 – CMArg