Ungroup graphs in batchs

  • Thread starter Thread starter richiwatts
  • Start date Start date
R

richiwatts

Hi,

As I didn't get an answer to my question about search and replace tex
in Microsoft graphs, i wonder if this is possible?

Is it possible, through a Macro or something, to ungroup all the graph
in a file? That way i will be able to search and replace all the text.

I have a lot of grapghs ad to go through an manually ungroup them woul
take for ever.

Many thanks
Rich
 
Hi Richi,
Try this in vba. You need to add a reference to ms graph and ms powerpoint.
Kurt

Dim pp As New PowerPoint.Application
Dim slide As PowerPoint.slide
Dim shape As PowerPoint.shape
Dim graph As graph.Chart

For Each slide In pp.ActivePresentation.Slides
For Each shape In slide.Shapes
If shape.Type = msoEmbeddedOLEObject Then
If Left(shape.OLEFormat.ProgId, Len("MSGraph.Chart")) =
"MSGraph.Chart" Then
Set graph = shape.OLEFormat.object
If graph.HasTitle Then
graph.ChartTitle = "New title"
End If
End If
End If
Next
Next
 
Hi Richi,
Try this in vba. You need to add a reference to ms graph and ms powerpoint.
Kurt

Dim pp As New PowerPoint.Application
Dim slide As PowerPoint.slide
Dim shape As PowerPoint.shape
Dim graph As graph.Chart

For Each slide In pp.ActivePresentation.Slides
For Each shape In slide.Shapes
If shape.Type = msoEmbeddedOLEObject Then
If Left(shape.OLEFormat.ProgId, Len("MSGraph.Chart")) =
"MSGraph.Chart" Then
Set graph = shape.OLEFormat.object
If graph.HasTitle Then
graph.ChartTitle = "New title"
End If
End If
End If
Next
Next
 
Kurt,

Thanks for posting this - as written, it changes the title of the graph.
richiwatts wants to ungroup them, so ...

Sub UngroupGraphs()

' Not needed if run from within PPT
' Dim pp As New PowerPoint.Application

Dim slide As PowerPoint.slide
Dim shape As PowerPoint.shape

' Not needed since we're not going to address the graph object model
' Dim graph As graph.Chart

' And since we're not addressing the graph object model, there's no need
' to set a reference to it

For Each slide In ActivePresentation.Slides
For Each shape In slide.Shapes
If shape.Type = msoEmbeddedOLEObject Then
If Left(shape.OLEFormat.ProgID, _
Len("MSGraph.Chart")) = "MSGraph.Chart" Then
' Ungroup and regroup the shape
Set shape = shape.Ungroup.Group
' Or just ungroup if preferred:
' Set shape = shape.Ungroup
End If
End If
Next
Next
End Sub
 
Hi Steve,
Yes I know. It was a bit confusing but his original question was about
changing text in a chart (the unanswered one)... Couldn't harm.
 
Hi Steve,
Yes I know. It was a bit confusing but his original question was about
changing text in a chart (the unanswered one)... Couldn't harm.

Nope, and it gave me something to bounce off. Two problems solved. Our work
on this planet's done. Time for a cold one ...your turn to buy, isn't it? ;-)
 
Back
Top