Cutter
02-24-2019, 07:50 AM
Good morning all.
I have run into a problem that I haven't been able to solve by searching.
I have a series of Rectangles with Top Rounded Corners (AutoShapeType 152). I am trying to assign a single macro to perform various tasks depending on the Text within the Shape. To do that I am trying to get the Text of the Shape using ActiveSheet.Shapes(Application.Caller). This method works fine with a Rectangle with Rounded Corners (AutoShapeType 5) but not with Type 152. I can carry on using the Type 5 but I'm determined to know why this is giving an error. Thanks for your interest.
The simplified code is:
Sub ShapeTest()
Dim shp As Shape, str As String
Set shp = ActiveSheet.Shapes(Application.Caller)
str = shp.TextFrame.Characters.Text
MsgBox str
End Sub
The result is: Run-time error '-2147024809 (80070057)': The item with the specified name wasn't found
On Debug the highlighted line is: Set shp = ActiveSheet.Shapes(Application.Caller)
I have run into a problem that I haven't been able to solve by searching.
I have a series of Rectangles with Top Rounded Corners (AutoShapeType 152). I am trying to assign a single macro to perform various tasks depending on the Text within the Shape. To do that I am trying to get the Text of the Shape using ActiveSheet.Shapes(Application.Caller). This method works fine with a Rectangle with Rounded Corners (AutoShapeType 5) but not with Type 152. I can carry on using the Type 5 but I'm determined to know why this is giving an error. Thanks for your interest.
The simplified code is:
Sub ShapeTest()
Dim shp As Shape, str As String
Set shp = ActiveSheet.Shapes(Application.Caller)
str = shp.TextFrame.Characters.Text
MsgBox str
End Sub
The result is: Run-time error '-2147024809 (80070057)': The item with the specified name wasn't found
On Debug the highlighted line is: Set shp = ActiveSheet.Shapes(Application.Caller)