I have one Excel file that has a Chart (Bar Chart). I also have a Powerpoint presentation with 3 slides. Please note that there is no chart "Title" either on the Excel sheet ot on the Powerpoint slides. I need to update the chart in slide #2 with the the chart in the excel file.
Please note that I have searched this forum and what I found was ways to create a new slide as well as updating a chart using the tittle.
Any help will be greatly appreciated. Thanks for your time
EDIT: Your solution is good but does not help me with how to replace a chart in a particular slide. In my question I have stated that there are 3 slides. I want to specifically update the chart in Slide 2. There is no chart title so I will need to find the Chart to replace based on the Slide number. How is this done ? Thanks again.
This can be done by following these steps: (Note: the powerpoint is the target, and the excel is the source)
Save the source and leave the file open.
Open the source and locate the ChartPart that you want to copy to the target. It will be in a DrawingsPart of a WorksheetPart somewhere in your source. Keep a reference to the ChartPart and leave the file open.
In the SlidePart reference from step 1, create a new ChartPart with the AddNewPart call using the RelationshipId
Copy the contents of the source chart to the new chartpart you created in step 4 with a FeedData/GetStream idea found here. Save the Slide, and close your files.
I was able to get it to work with a simple source/target that only contained one chart each. If your files are more complex, your locate logic will be more than a First().
Hope this helps.