0

I use a function to update charts in my presentation. This presentation needs to be shared, but will also be updated periodically. Now, I copy the presentation to keep the original presentation for updates, and unlink all charts one-by-one. I am searching for a function that will unlink all charts once I copied the presentation to be able to share it.

Is there a function that will solve this issue?

function createRefreshSheetsChartsRequests(presentation) { var objectIds = []; var slides = presentation.slides;
  for (var i = 6; i < slides.length - slides.length + 9; i++) {
    var slide = slides[i];
    var pageElements = slide.pageElements;
    for (var j = 0; j < pageElements.length; j++) {
      var pageElement = pageElements[j];
      if (pageElement.sheetsChart) {
        objectIds.push(pageElement.objectId);
      }
    }
  }
  return objectIds.map(function(objectId) {
    return {refreshSheetsChart: {objectId: objectId}};
  });
}    
Dharman
  • 30,962
  • 25
  • 85
  • 135
Lars L
  • 1
  • 1
  • 1

2 Answers2

1

There's no API to unlink a chart in the Slides API. You have a few options though:

  • Delete the chart and reinsert as an image. You can do this either with CreateSheetsChartRequest with LinkingMode.NOT_LINKED_IMAGE or with CreateImageRequest using the URL you get from the GET APIs in the SheetsChart.content_url field. You'll have to take care that the new chart is positioned and sized to match the existing one.

  • Update the sharing permissions on the spreadsheet the chart came from. If the user you share the presentation with doesn't have read access to the underlying spreadsheet, they cannot refresh the chart in Slides, so can't see the new data.

If you're interested in an unlink API, you can file a feature request here.

Maurice Codik
  • 598
  • 2
  • 6
1

Simple. Download Google Presentation as a PowerPoint. Don't even bother opening in with PowerPoint - just re-upload it again to your Google Drive. Same Google Presentation re-appears, but WITHOUT the links. Beautiful

  • From Review: Hi, this post does not seem to provide a [quality answer](https://stackoverflow.com/help/how-to-answer) to the question. Please either edit your answer and improve it, or just post it as a comment. – sɐunıɔןɐqɐp Nov 12 '19 at 00:09
  • Hi, not sure about the quality of this answer, but It worked for what I needed. Thanks for sharing! – JotaTRod Jun 11 '21 at 14:40