PC Review


Reply
Thread Tools Rate Thread

Access to all the shapes of a diagram in .NET and in VBA

 
 
=?Utf-8?B?TWFyYyBSaWRleQ==?=
Guest
Posts: n/a
 
      9th Sep 2005
I'm trying to get reformat the shapes used in a diagram in a PowerPoint 2003
presentation.

If I try to access .GroupItems on a shape of type msoDiagram, I get an
Exception, both in VBA and in .NET C# that reads: This member can only be
accessed for a group

But ...

In the watches window, if I place the same object, I can navigate to the
GroupItems property and it contains correctly all the shapes of the diagram
and if I modify the properties of the shapes such as colors in the watches
window, then the diagram is changed.

Is there a way to work around the exception since the data is there to be
accessed?


 
Reply With Quote
 
 
 
 
Shyam Pillai
Guest
Posts: n/a
 
      9th Sep 2005
Marc,
Try:

Dim oShp As Shape
Dim oDgm As Diagram
Dim oNodeShp As Shape
Dim I As Integer
' Assuming that the selected shape is a diagram
Set oShp = ActiveWindow.Selection.ShapeRange(1)
Set oDgm = oShp.Diagram
For I = 1 To oDgm.Nodes.Count
' To get a reference to the shape of the current node
' Set oNodeShp = oDgm.Nodes(I).Shape

' To get the text of the current node
Debug.Print oDgm.Nodes(I).TextShape.TextFrame.TextRange.Text
Next


--
Regards,
Shyam Pillai

Toolbox: http://skp.mvps.org/toolbox

"Marc Ridey" <(E-Mail Removed)> wrote in message
news:2814AA2A-D1DD-4AE3-9797-(E-Mail Removed)...
> I'm trying to get reformat the shapes used in a diagram in a PowerPoint
> 2003
> presentation.
>
> If I try to access .GroupItems on a shape of type msoDiagram, I get an
> Exception, both in VBA and in .NET C# that reads: This member can only be
> accessed for a group
>
> But ...
>
> In the watches window, if I place the same object, I can navigate to the
> GroupItems property and it contains correctly all the shapes of the
> diagram
> and if I modify the properties of the shapes such as colors in the watches
> window, then the diagram is changed.
>
> Is there a way to work around the exception since the data is there to be
> accessed?
>
>



 
Reply With Quote
 
=?Utf-8?B?TWFyYyBSaWRleQ==?=
Guest
Posts: n/a
 
      9th Sep 2005
It would be great but there is a bug in PowerPoint and both the .Shape and
..TextShape properties of the DiagramNode clas return the Text shape of the
diagram. There is no access to the arrow shape of the diagram (in case of a
cycle diagram for example).

So the question remains: How do I get access to all the shapes that form the
diagram?
 
Reply With Quote
 
Shyam Pillai
Guest
Posts: n/a
 
      9th Sep 2005
See my reply to your other post.

--
Regards,
Shyam Pillai

Image Importer Wizard: http://skp.mvps.org/iiw.htm

"Marc Ridey" <(E-Mail Removed)> wrote in message
news:285D1994-1BD2-4970-843B-(E-Mail Removed)...
> It would be great but there is a bug in PowerPoint and both the .Shape and
> .TextShape properties of the DiagramNode clas return the Text shape of the
> diagram. There is no access to the arrow shape of the diagram (in case of
> a
> cycle diagram for example).
>
> So the question remains: How do I get access to all the shapes that form
> the
> diagram?



 
Reply With Quote
 
=?Utf-8?B?TWFyYyBSaWRleQ==?=
Guest
Posts: n/a
 
      9th Sep 2005
It's weird. I've spent the afternoon at work on this and I kept getting the
exception on the access to the GroupItems property : This memeber can only be
accessed for a Group.

I've tested both C#.Net using Interop and direct VBA Macro and both failed.
I'm now at home and tested you code and some of my tests and all work ... and
it's Office 2003 in both cases.

Thanks anyway. At least it shows me that it should work. Now I have to
figure out why in some cases it doesn't work.
 
Reply With Quote
 
=?Utf-8?B?TWFyYyBSaWRleQ==?=
Guest
Posts: n/a
 
      9th Sep 2005
Sometimes PowerPoint makes me want to cry.
Here's a new one:

I'm at home and testing the GroupItems property. Yes, I can access it fine
but the GruopItems.Count remains a constant. I have a Macro assigned to a
button on a toolbar with your exact code.

I insert a new diagram, select it, press the button and the 6 shapes are
accessed. Then I insert a new node, so there's 8 shapes. I press the button
and only 6 shapes are read. I insert more and more, still only 6 shapes are
read. .GroupItems.COunt remain equal to 6. I copy/delete/paste the diagram
and the GroupItems.Count value is reset to the right number of shapes in the
diagram.


 
Reply With Quote
 
Shyam Pillai
Guest
Posts: n/a
 
      9th Sep 2005
Marc,
I cannot reproduce it. The count changes to reflect any shapes added/removed
from the diagram.


--
Regards,
Shyam Pillai

Image Importer Wizard: http://skp.mvps.org/iiw.htm
"Marc Ridey" <(E-Mail Removed)> wrote in message
news:EC43D7E9-8866-4A4D-83BA-(E-Mail Removed)...
> Sometimes PowerPoint makes me want to cry.
> Here's a new one:
>
> I'm at home and testing the GroupItems property. Yes, I can access it fine
> but the GruopItems.Count remains a constant. I have a Macro assigned to a
> button on a toolbar with your exact code.
>
> I insert a new diagram, select it, press the button and the 6 shapes are
> accessed. Then I insert a new node, so there's 8 shapes. I press the
> button
> and only 6 shapes are read. I insert more and more, still only 6 shapes
> are
> read. .GroupItems.COunt remain equal to 6. I copy/delete/paste the diagram
> and the GroupItems.Count value is reset to the right number of shapes in
> the
> diagram.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Diagram Access DB Process with Visio Chris Moore Microsoft Access Database Table Design 3 6th Oct 2009 04:06 PM
How do I change the Diagram Style (in the Cycle Diagram) to ARROW. =?Utf-8?B?UGFtTA==?= Microsoft Powerpoint 4 24th Mar 2005 05:55 AM
RESIZING OF DIAGRAM (Access 97 msgraph) Udo Pecher Microsoft Access 0 3rd Oct 2004 08:30 AM
Access ADP - SQL server diagram conflicts. Jon Microsoft Access 3 21st Jun 2004 08:51 PM
Diagram Reports in Access (or Visio) Doh Boy Microsoft Access Reports 4 12th Jul 2003 11:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:04 PM.