Forum Discussion
Access of Text in an Excel Autoshape with vba
Hallo Hans,
thank you very much. I have found this method at several places in the internet. But, why does not work?
Do you get an error message? If so, what does it say?
- ber999Jan 15, 2021Brass Contributor
Hi Hans,
thank you for the answer. It seems that some shapetypes have a different object model. I am looking for an object model for the Autoshapes. HansVogelaar
- HansVogelaarJan 15, 2021MVP
The code works in the workbook that you attached. I'd have to see an example of where it fails.
- ber999Jan 15, 2021Brass Contributor
Hi Hans,
thank you very much. I have copied the Autoshape at the attached sheet from a worksheet with hundreds of different shapes. My vba code did not work there with the Autoshapes only.I have found code for Powerpoint Autoshapes. The access method is different there (see below).
Dim shpTextArray() As Variant
Dim numShapes, numAutoShapes, i As Long
Set myDocument = ActivePresentation.Slides(1)
With myDocument.Shapes
numShapes = .Count
If numShapes > 1 Then
numTextShapes = 0
ReDim shpTextArray(1 To 2, 1 To numShapes)
For i = 1 To numShapes
If .Item(i).HasTextFrame Then
numTextShapes = numTextShapes + 1
shpTextArray(numTextShapes, 1) = .Item(i).Name
shpTextArray(numTextShapes, 2) = .Item(i) _
.TextFrame.TextRange.Text
End If
Next
ReDim Preserve shpTextArray(1 To 2, 1 To numTextShapes)
End If
End With