Reputation: 457
I'm using SlidesApp.getActivePresentation.getSlides[0].getPageElements()[0].asShape().getText().asString()
to get the text of the title of the slide. However, when I try to check the text in an equality statement like SlidesApp.getActivePresentation.getSlides[0].getPageElements()[0].asShape().getText().asString() == "XYZ Company"
it returns false
. What do I need to do to accurately check that a given Slide page element textbox contains certain text?
Upvotes: 0
Views: 558
Reputation: 457
It seems the type of textbox was adding a trailing line break, so s.getPageElements()[0].asShape().getText().asString().trim() == "XYZ Company"
evaluates true
Upvotes: 0
Reputation: 4048
You can also try using the JavaScript String includes() method as it will only check if a string includes the word you're looking for & it will disregard any new lines or spaces on the string. See this sample below:
function test() {
var slide = SlidesApp.getActivePresentation().getSlides()[0].getPageElements()[0].asShape().getText().asString();
Logger.log(slide.includes("XYZ Company"));
}
Upvotes: 1