P
pH7
The oval shapes on the drawing layer are grouped, some under one grou
and some under another group. This function is called for each to
level group. The following function works in Excel 97 and 2000 bu
fails on the line that says “test_string
in_shape.TextFrame.Characters.Text” with a Type mismatch error in Exce
XP. An alternate version that uses instead the 2 commented lines work
in 2000 and XP but not Excel 97. I would like to find something tha
works in all versions. Any ideas?
Code
-------------------
Function match_letter(in_shape As Shape, dimension_letter As String) As Boolean
' This function will act differently depending on the type of in_shape.
' If in_shape is a oval or callout, then the text will be compared to the dimension_letter
' that we are seeking. If it is a match we will return True otherwise return false.
' If in_shape is a group, then this function will call itself recursively to look for
' a shape in this group that is a match. If a shape in the group matches, return
' True, otherwise continue to search.
Dim sh As Shape
Dim save_group As ShapeRange
Dim test_string As String
return_value = False
If in_shape.Type = msoCallout Or _
(in_shape.Type = msoAutoShape And in_shape.AutoShapeType = msoShapeOval) Then
' test_string = in_shape.AlternativeText
' test_string = Mid(test_string, 11)
test_string = in_shape.TextFrame.Characters.Text
If test_string = Trim(dimension_letter) Then
return_value = True
End If
ElseIf in_shape.Type = msoGroup Then
For Each sh In in_shape.GroupItems
return_value = match_letter(sh, dimension_letter)
If return_value Then Exit For
Next
End If
match_letter = return_value
End Function
and some under another group. This function is called for each to
level group. The following function works in Excel 97 and 2000 bu
fails on the line that says “test_string
in_shape.TextFrame.Characters.Text” with a Type mismatch error in Exce
XP. An alternate version that uses instead the 2 commented lines work
in 2000 and XP but not Excel 97. I would like to find something tha
works in all versions. Any ideas?
Code
-------------------
Function match_letter(in_shape As Shape, dimension_letter As String) As Boolean
' This function will act differently depending on the type of in_shape.
' If in_shape is a oval or callout, then the text will be compared to the dimension_letter
' that we are seeking. If it is a match we will return True otherwise return false.
' If in_shape is a group, then this function will call itself recursively to look for
' a shape in this group that is a match. If a shape in the group matches, return
' True, otherwise continue to search.
Dim sh As Shape
Dim save_group As ShapeRange
Dim test_string As String
return_value = False
If in_shape.Type = msoCallout Or _
(in_shape.Type = msoAutoShape And in_shape.AutoShapeType = msoShapeOval) Then
' test_string = in_shape.AlternativeText
' test_string = Mid(test_string, 11)
test_string = in_shape.TextFrame.Characters.Text
If test_string = Trim(dimension_letter) Then
return_value = True
End If
ElseIf in_shape.Type = msoGroup Then
For Each sh In in_shape.GroupItems
return_value = match_letter(sh, dimension_letter)
If return_value Then Exit For
Next
End If
match_letter = return_value
End Function