Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to access textrange members inside SmartArt

137 views
Skip to first unread message

Caio Milani

unread,
Sep 4, 2009, 3:12:01 PM9/4/09
to
Hi,

I am trying to access textrange.text property inside a msoSmartArt

if I use the code below I get

"member can only be accessed for a single shape" at Debug.print line

For Each oShp In oSld.Shapes
With oShp
If .Type = msoSmartArt Then
For x = 1 To .GroupItems.Count
With .GroupItems(x)
If .HasTextFrame Then
If .TextFrame.HasText Then
Debug.Print .TextFrame.TextRange.text
End If
End If
End With
Next x
End If

The .GroupItems(x).TextFrame.TextRange.Count returns 3. At the locals window
a can see that each of these 3 object refers to each line of text inside the
shape.

How do I access the collection members?
I tried

.GroupItems(x).TextFrame.TextRange(1).TextRange.text and it fails.

John Wilson

unread,
Sep 5, 2009, 2:08:01 AM9/5/09
to
The groupitems are read only. Don't ask me why , I don't know.
--
john ATSIGN PPTAlchemy.co.uk

Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
PPTLive Atlanta Oct 11-14 2009

Steve Rindsberg

unread,
Sep 5, 2009, 1:17:11 PM9/5/09
to
This slightly modified version works here. All I've really done is change the
variable names and added the missing End With, etc.

It may have to do with the type of smartart, but also, have you applied any
Service Packs? As it happens, I did this in a computer with SP1 installed.

Dim oSh As Shape
Dim oSl As Slide
Dim x As Long

Set oSl = ActivePresentation.Slides(1)

For Each oSh In oSl.Shapes
With oSh


If .Type = msoSmartArt Then
For x = 1 To .GroupItems.Count
With .GroupItems(x)
If .HasTextFrame Then
If .TextFrame.HasText Then

Debug.Print .TextFrame.TextRange.Text


End If
End If
End With
Next 'x
End If

End With
Next

End Sub

In article <04CE56A9-4AAA-4CB2...@microsoft.com>, Caio Milani
wrote:

> ..GroupItems(x).TextFrame.TextRange(1).TextRange.text and it fails.


==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/

Don't Miss the PPTLive User Conference! Atlanta | Oct 11-14

Caio Milani

unread,
Sep 15, 2009, 6:36:10 PM9/15/09
to
I'm not even trying to modify it. I just want to access and read the text.
But it is a collection.

Caio Milani

unread,
Sep 15, 2009, 6:43:03 PM9/15/09
to
Yes, it has to do with the type of smart art. Some types of smart art have a
collection inside the .TextFrame.TextRange, hence it's not possible to
access the .TextFrame.TextRange.text property. Error "member can only be
accessed for a single shape"

Therefore I'm trying to find a way to access each member of the
.TextFrame.TextRange collection and then the text property

Steve Rindsberg

unread,
Sep 16, 2009, 1:35:25 PM9/16/09
to
I see. So let us know the steps to create one of the problem smart art types so we
can try it here.

In article <AE337FAA-B39A-4D76...@microsoft.com>, Caio Milani wrote:
> Yes, it has to do with the type of smart art. Some types of smart art have a
> collection inside the .TextFrame.TextRange, hence it's not possible to
> access the .TextFrame.TextRange.text property. Error "member can only be
> accessed for a single shape"
>
> Therefore I'm trying to find a way to access each member of the

> ..TextFrame.TextRange collection and then the text property

Arie Livshin

unread,
Sep 16, 2010, 6:07:39 AM9/16/10
to
for (int i=1;i<=textRange.Count;i++)
{
TextRange ranger=textRange._item(1);
.......
}

(or equivalent code in VB)


Arie


>> On Saturday, September 05, 2009 2:08 AM John Wilson wrote:

>> The groupitems are read only. Don't ask me why , I do not know.


>> --
>> john ATSIGN PPTAlchemy.co.uk
>>
>> Free PPT Hints, Tips and Tutorials
>> http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
>> PPTLive Atlanta Oct 11-14 2009
>>
>>
>>
>>
>> "Caio Milani" wrote:


>>> On Saturday, September 05, 2009 1:17 PM Steve Rindsberg wrote:

>>> This slightly modified version works here. All I have really done is change the


>>> variable names and added the missing End With, etc.
>>>
>>> It may have to do with the type of smartart, but also, have you applied any
>>> Service Packs? As it happens, I did this in a computer with SP1 installed.
>>>
>>> Dim oSh As Shape
>>> Dim oSl As Slide
>>> Dim x As Long
>>>
>>> Set oSl = ActivePresentation.Slides(1)
>>>
>>> For Each oSh In oSl.Shapes
>>> With oSh

>>> If .Type = msoSmartArt Then
>>> For x = 1 To .GroupItems.Count
>>> With .GroupItems(x)
>>> If .HasTextFrame Then
>>> If .TextFrame.HasText Then

>>> Debug.Print .TextFrame.TextRange.Text


>>> End If
>>> End If
>>> End With
>>> Next 'x
>>> End If

>>> End With
>>> Next
>>>
>>> End Sub
>>>
>>> wrote:
>>>
>>>
>>> ==============================
>>> PPT Frequently Asked Questions
>>> http://www.pptfaq.com/
>>>
>>> PPTools add-ins for PowerPoint
>>> http://www.pptools.com/
>>>
>>> Don't Miss the PPTLive User Conference! Atlanta | Oct 11-14


>>>> On Tuesday, September 15, 2009 6:36 PM Caio Milani wrote:

>>>> I am not even trying to modify it. I just want to access and read the text.


>>>> But it is a collection.
>>>>
>>>> "John Wilson" wrote:


>>>>> On Tuesday, September 15, 2009 6:43 PM Caio Milani wrote:

>>>>> Yes, it has to do with the type of smart art. Some types of smart art have a

>>>>> collection inside the .TextFrame.TextRange, hence it is not possible to
>>>>> access the .TextFrame.TextRange.text property. Error "member can only be


>>>>> accessed for a single shape"
>>>>>

>>>>> Therefore I am trying to find a way to access each member of the


>>>>> .TextFrame.TextRange collection and then the text property
>>>>>
>>>>> "Steve Rindsberg" wrote:


>>>>>> On Wednesday, September 16, 2009 1:35 PM Steve Rindsberg wrote:

>>>>>> I see. So let us know the steps to create one of the problem smart art types so we
>>>>>> can try it here.
>>>>>>
>>>>>>
>>>>>>

>>>>>> ==============================
>>>>>> PPT Frequently Asked Questions
>>>>>> http://www.pptfaq.com/
>>>>>>
>>>>>> PPTools add-ins for PowerPoint
>>>>>> http://www.pptools.com/
>>>>>>
>>>>>> Don't Miss the PPTLive User Conference! Atlanta | Oct 11-14


>>>>>> Submitted via EggHeadCafe - Software Developer Portal of Choice
>>>>>> ComponentOne Studio for ASP.NET AJAX - Free License Giveaway
>>>>>> http://www.eggheadcafe.com/tutorials/aspnet/ce98ce1f-2b5d-4ec8-b6d5-a1049651514e/componentone-studio-for-aspnet-ajax--free-license-giveaway.aspx

0 new messages