Reputation: 423
In my Google slideshow, I have a table. The table updates every 15 minutes. I have cells in this table that I want to include hyperlinks. I tried to manually enter a hyperlink by highlighting the text in the cell and right clicking, selecting "link". But when the table updates the hyperlinks gets removed. I've tried both setText() and insertText() in the script, both erase the links.
I've also looked into having the link automatically be re-added once the update was done, however slideshow tables don't have an insertLink command. Also, as this table is not actually a Google Spreadsheet, there is no setFormula() command.
Here is what I'm currently using to update the table. Works, just need hyperlinks added to the text.
FYI the links will be to other files in the Google Drive, if that matters...
var slide = SlidesApp.getActivePresentation().getSlides()[slideNo];
var table = slide.getTables();
var cell = table[0].getCell(row,4);
var trafficTime = convertTime(res["routes"][0]["summary"]["travelTimeInSeconds"]);
var trafficDelay = Math.round(res["routes"][0]["summary"]["trafficDelayInSeconds"]/60);
var displayedTime = trafficTime + " +" + trafficDelay;
cell.getText().clear();
cell.getText().insertText(0,displayedTime);
Upvotes: 1
Views: 735
Reputation: 201673
If my understanding is correct, how about this modification? Please think of this as just one of several possible answers.
TextRange
returned from insertText
can be used. For this, you can use the method of getTextStyle().setLinkUrl(URL)
.When your script is modified, please modify as follows.
From:cell.getText().insertText(0,displayedTime);
To:
var textRange = cell.getText().insertText(0,displayedTime);
textRange.getTextStyle().setLinkUrl(url);
or
cell.getText().insertText(0,displayedTime).getTextStyle().setLinkUrl(url);
url
is a string type like https://###sample###/
.If I misunderstood your question and this was not the direction you want, I apologize.
Upvotes: 1