VBA - Find Shapes (chart) in an powerpoint slide

RuiFlora

Board Regular
Joined
Feb 28, 2014
Messages
58
Hello, I am trying to build a code that pulls data from an access database and fills charts in a powerpoint file with a template. This template has two charts initially built in 97-2003 format but i'm trying to update them to office 2013 charts.

I am running a macro that finds all the shapes available in the slide. The problem here is that the loop find everything (titles, footpages, excel 2003 shapes) but can't find the 2013 chart that I inserted in the template. Here is the code I have:

Private Function GetChartObject(ByVal sl As powerpoint.Slide, ByVal ChartIndex As Integer) As graph.Chart


Dim strChartName As String
Dim sh As powerpoint.Shape
Dim ch As graph.Chart


strChartName = "Chart" & Trim(CStr(ChartIndex))


For Each sh In sl.Shapes
If sh.AlternativeText = strChartName Then
Set ch = sh.OLEFormat.Object
Exit For
End If
Next sh


Set GetChartObject = ch


End Function
----------------------------------------------------------------------
If someone can help me finding out why the 2013 graph is not detected by the loop would great!

Thanks in advance!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
I'm sorry to post a powerpoint related question but I am actually running that macro from an excel file, which have all the settings to run properly the sql queries for acccess.
 
Upvote 0

Forum statistics

Threads
1,213,544
Messages
6,114,239
Members
448,555
Latest member
RobertJones1986

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top