In this video, you will connect your Slides presentation to the script editor.
This makes it possible to program the code that changes how the application works.
To start, add four more slides to your presentation.
Your code will count how many slides there are and make a progress bar of the correct length -- in this case, five slides.
Next, open the script editor, and name your project.
In these lessons, you will program all your code within the my function brackets.
A function is a procedure or routine.
Inside the function, you will program a variable.
A variable is a container that stores values.
In this case, the variable will store the values that connect your code to your presentation.
You will use many variables to create your progress bar.
Now, place your cursor on the line after the open bracket.
Then, declare a variable called slides.
Type: V-A-R slides To get the contents of your presentation, type equals then, slides app.
Make sure the capitalization and spacing exactly match what you see on screen.
Then, type a period to open the autocomplete menu.
From the menu, select get active presentation.
Type another period, and select get slides.
Your code now reads: Create a variable called slides, and in that variable, store all the slides in the current presentation.
Save and run your program.
When your code runs, it accesses information from your slides.
To ensure your privacy is protected, you must give your permission before the script accesses a file from your Google account.
Depending on your privacy settings, you may need to authorize Apps Script to access your slides.
Use advanced settings to run your program.
Now, save and run your program again.
This program runs without errors, but sometimes your script will encounter a problem, and an error message will appear.
Don’t worry; even the most experienced developers make mistakes writing code.
Look at this example error message.
It says there is a type error.
Forgetting to capitalize something is a very common programming mistake.
In this example, capitalizing the S should fix the error.
At this point, your presentation is still blank, but in the next video, you add shapes to your progress bar.
Now, it’s your turn: add four more slides to your presentation, open the script editor, and name your project, create a variable to store the presentation, save and run the program, and troubleshoot any error messages.
1. Introduction to Program a Progress Bar in Google Slides
2. Program a Variable
3. Program a Shape
4. Use a Loop to Draw Multiple Shapes
5. Use a Loop to Add Shapes to Every Slide
6. Program a Conditional Statement
7. Program a Progress Bar in Google Slides Wrap-Up
9. Extensions: Program a Progress Bar