-1

I have a bunch of URLs in a google sheets doc and I want to reference them in my current code so they will then insert into a google slides presentation.

Here's my current code:

var NAME = ("Price Changes, Earnings Revisions and F-GPE");
var deck = SlidesApp.openById("1dKURl3umVd3A6M5fbbm1SY1W-NzaaCNW-5rPtTKuNYw");
var layoutslide = SlidesApp.openById("1dKURl3umVd3A6M5fbbm1SY1W-NzaaCNW-5rPtTKuNYw").getSlides()[2];
var layout = layoutslide.getLayout();
//var layoutname = layout.getLayoutName();
/**
* Creates a single slide using the image from the given link;
* used directly by foreach(), hence the parameters are fixed.
*
* @param {Date} link A String object representing an image URL
* @param {Date} index The index into the array; unused (req'd by forEach)
* Sets the desired images height and width
* Gets the images's height and width and centres the image
*/
function addImageSlide(imageUrl, index) {
var layout = layoutslide.getLayout();
//var layoutname = layout.getLayoutName();
var slide = deck.appendSlide(layout);
var image = slide.insertImage(imageUrl);
var setimgwdth = image.setWidth(700);  
var setimghght = image.setHeight(430);
var imgWidth = image.getWidth();
var imgHeight = image.getHeight();  
var pageWidth = deck.getPageWidth();  
var pageHeight = deck.getPageHeight();
var newX = pageWidth/2. - imgWidth/2.;
var newY = pageHeight/2. - imgHeight/2.;
image.setLeft(newX).setTop(newY);
}

/**
* The driver application features an array of image URLs, setting of the
* main title & subtitle, and creation of individual slides for each image.
*/
function main() {
var images = [
             "https://product.datastream.com/dscharting/gateway.aspx?guid=a82ade99-e810-463e-9b21-8380971a7488&action=REFRESH" ,
             "https://product.datastream.com/dscharting/gateway.aspx?guid=933e1953-fd5b-48d0-b9f5-28e9e6c5e01a&action=REFRESH" ,
             "https://product.datastream.com/dscharting/gateway.aspx?guid=9caf2c27-f5f3-4dfe-a784-3e964504dc03&action=REFRESH"

];
var [title, subtitle] = deck.getSlides()[0].getPageElements();
title.asShape().getText().setText("Price Changes, Earnings Revisions and F-GPE");
subtitle.asShape().getText().setText("SA INSPIRATION LIST");
images.forEach(addImageSlide);
}

Is there a way to also add quotations and a comma automatically to the urls.

Rubén
  • 34,714
  • 9
  • 70
  • 166
jack law
  • 11
  • 2

1 Answers1

0

What you can do is:

  1. Open the Spreadsheet you want to work on using openById and fetch the data using getRange.

    1. After you place the data in a certain variable, you can now open the active slide and post the contents using setText

when using setText from Slides API:

setText(SPREADHSHEET_DATA_USING_GETRANGE);

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56