I'm pulling data from a Google Sheet to create new Google Slides from a template. Everything works fine, but I can't figure out how to make text clickable as a link once I've replaced the template variable with the spreadsheet data.
How do I replace my website variable, company_website, with the website link AND make it clickable?
function createSlidesfromSheets() {
var dataSpreadsheetUrl = "https://docs.google.com/spreadsheets/d/xxxxxlink/edit"; //make sure this includes the '/edit at the end
var ss = SpreadsheetApp.openByUrl(dataSpreadsheetUrl);
var deck = SlidesApp.getActivePresentation();
var sheet = ss.getSheetByName('Sheet1'); // this needs to be the name of the sheet/feuille
var values = sheet.getRange('A2:M20').getValues(); //this is the range of data to create the slides from.
//Logger.log(values);
var slides = deck.getSlides();
var templateSlideOne = slides[0];
var templateSlideTwo = slides[1];
var presLength = slides.length;
values.forEach(function(page){
if(page[0]){
var company_name = page[0];
var company_country = page[1];
var company_city = page[2];
var company_website = page[3];
var company_description = page[4];
templateSlideOne.duplicate(); //duplicate the first template slide
templateSlideTwo.duplicate(); //duplicate the second template slide
slides = deck.getSlides(); //update the slides array for indexes and length
newSlideOne = slides[1]; // declare the copy to update of the first template slide (right after the first template's slide)
newSlideTwo = slides[3]; // declare the copy to update of the second template slide (right after the second template's slide)
var firstShapes = (newSlideOne.getShapes());
firstShapes.forEach(function(shape){
shape.getText().replaceAllText('{{company-name}}',company_name);
shape.getText().replaceAllText('{{company-city}}',company_city);
shape.getText().replaceAllText('{{company-country}}',company_country);
shape.getText().replaceAllText('{{company-website}}',company_website);
// how do I use setLinkUrl() to make the new company_website text a clickable link?
});
var secondShapes = (newSlideTwo.getShapes());
secondShapes.forEach(function(shape){
shape.getText().replaceAllText('{{company-name}}',company_name);
shape.getText().replaceAllText('{{company-description}}',company_description);
});
presLength = slides.length;
newSlideOne.move(presLength);
presLength = slides.length;
newSlideTwo.move(presLength);
} // end our conditional statement
}); //close our loop of values
}