Embed an Image in Your Spreadsheet
Transcript
In this video, you will add code that allows users to see a different image for each place in your area guide.
Providing interactive images for each location can help give your viewers a better idea of what to expect at each location.
To begin, create a column in your area guide for Image Links and format the column heading to match the others.
Then, adjust the column width to make it bigger.
You will paste embedded image links for each location in this column.
Later, your users will be able to click on this link to make the image appear in the sidebar.
Open Apps Script if it isn't open already, or if it closed when you refreshed your area guide.
Next, find the link for the Google Maps image you pasted into your code in the last video and cut the link.
Then, return to your area guide spreadsheet and paste the U-R-L into the image link column in the appropriate row.
Next return to your code and delete the single quotation marks that surrounded your link.
Then, in the parentheses, type "Spreadsheet App.Get Active Range", and add a set of parentheses.
Type a period after the set of parentheses.
An autocomplete menu appears with more options.
Select Get Display Value, and add a set of parentheses.
Clicking a cell makes it active.
These instructions tell the computer to return the values contained in the active range of cells and display them in the sidebar.
Try it out.
Save your code.
Then, run the onOpen function.
You may need to authorize the code again so your program can read information from the spreadsheet.
Return to the area guide sheet.
Click the cell where you pasted the URL for the image.
Then, open the sidebar.
The embedded image reloads in the sheet.
Great job.
Next, add another embedded image for a different location in your guide.
Find the location in Google Maps.
Get a streetview image.
Copy the embed a map U-R-L.
Then, paste the U-R-L into the appropriate row in your guide.
Click the cell with the new link and use the custom menu to update the sidebar.
Now your program works for any embedded link in the spreadsheet.
If your code didn't work, don't worry.
Check the punctuation and capitalization in your code carefully.
Make sure your code matches this code.
Now, it's your turn: Cut the embed image link from your code and paste it into your area guide sheet, add code so that the sidebar displays the image linked in the active range of the spreadsheet, add an embed image link for another location to your area guide, and test the code on your new image link.
Instructions
- Cut the embed image link from your code and paste it into your area guide sheet.
- Add code so that the sidebar displays the image linked in the active range of the spreadsheet.
- Add an embed image link for another location to your area guide.
- Test the code on your new image link.