I have an excel macro that draws some numbers from a database to populate an excel spreadsheet and then updates some graphs in a .pptx and sends it via outlook. It all works fine but now I really want to break the links in all graphs to avoid people accidentially updating the data (the reports are supposed to show data from a specific date).
I found a solution that worked well from inside powerpoint and tried to do something similar in my vba macro. When I run my modified macro now I get this error though: "Run-time error: Method 'BreakLink' of object 'LinkFormat' failed"
Here is the snippet of my code that concerns the linkbreaking:
- 'Load ppt
- Set Ppt1 = PptApp.Presentations.Open(PptPath, msoFalse, msoTrue, msoFalse)
- 'Break links
- Dim shp As PowerPoint.Shape
- Dim sld As PowerPoint.Slide
- For Each sld In Ppt1.Slides
- For Each shp In sld.Shapes
- If shp.Type = msoLinkedOLEObject Then
- End If
- Next shp
- Next sld
- 'Save file
- NewPath = HomePath & "Rapporter\2015\" & Format(Date - i, "yyyymmdd") & " Daily report"
- Ppt1.SaveCopyAs (NewPath)
The vba editor recognizes the BreakLink method (suggests it), and I referenced the PowerPoint object library. Any ideas to what may cause this error and how to fix it - or an alternate method entirely to remove the links.
Thanks in advance
Edit: I use Office 2013 in case that might be important.