Members-only tutorial

Watch the video and get the practice sheet with membership.

See membership options

Enter Google Drive File Name Get URL

About this Tutorial

Create a simple automation with an installable trigger that allows you to enter the Google Drive file name and get the URL inside your Google Sheet.

Video Transcript

<div>0:00 So we had a member ask, can you insert a file into a Google sheet cell? And a very interesting answer is, well no.<br>0:10 But that's not what's interesting about it. What's interesting about it is, sort Learn how to organize your data effectively with sorting techniques. Opens in new tab of, you can sort Learn how to organize your data effectively with sorting techniques. Opens in new tab of do it. So, what the work around and their work around is, they have a Google Drive file, they put a file in Google Drive, and then they put a URL inside of a- Google sheet cell.<br>0:26 And they want to know, is there a better way? And I can sort Learn how to organize your data effectively with sorting techniques. Opens in new tab of just automate that.

So, well, no, you can't insert a file into a Google sheet cell.<br>0:37 You can make the process of putting a URL of a Google Drive file much easier. Alright, let me share Discover how to share your Google Sheets with others seamlessly. Opens in new tab with you how this works.<br>0:48 So, essentially, I want to take the name of a Google Sheet file. Like, I have a Google Sheet, uh, a Google document called Google Sheet's template Explore various templates to streamline your Google Sheets projects. Opens in new tab .<br>0:58 I'm gonna just type that in there. And I want the URL to show up here.

Because the way that I would do this normally is I would go to Google Drive, drop that file in, and figure out what the URL is, and copy the URL over here.<br>1:12 But I- know the name of it. And at least, if it's got a unique Find out how to extract unique values from your data in Google Sheets. Opens in new tab name, I can do this. So let's go do this right now.<br>1:18 Let's go do extensions, appscript, and it's only gonna be a few lines of code. But there is one big trick with it.<br>1:25 And I'm gonna show you. We're gonna run into an error Get insights on common Google Sheets errors and how to fix them. Opens in new tab . I'm gonna fix that error Get insights on common Google Sheets errors and how to fix them. Opens in new tab in this video. Okay. I'm just zoomed in a little.<br>1:36 Too much. There we go. So let's call this.

Enter file name. Get URL. And our function Understand the basics of functions in Google Sheets for better calculations. Opens in new tab at first, I thought, let's do on edit.<br>1:50 You have an event or e. And then we were. Anytime there's an edit, we're going to run a function Understand the basics of functions in Google Sheets for better calculations. Opens in new tab called get URL that will.<br>2:00 Create, and we just wanted to use the file name here, and we're going to return. The file name here, or sorry, the URL here.<br>2:13 If we have the file name, we can do something very quick. And say variable files equals drive app that get files.<br>2:24 By name. And we can just look for the file name.

And the one weird thing, before we get to the error Get insights on common Google Sheets errors and how to fix them. Opens in new tab that's going to happen, is we can do variable file equals files.next.<br>2:43 So that's the weird thing right here, is this is going to give us back a list of files. Even if it's one file, we have to use this files.next to get the file.<br>2:54 And then we can get file.getURL. Three lines of code right there to enter a file name and get a URL.<br>3:02 But we want to be able to do that quote unquote automatically.

We want to be able to enter a file name here and get the URL here.<br>3:09 Well, how do we know if we're editing here and we have a value? That's where Learn how to use the query where clause for advanced data filtering. Opens in new tab we where Learn how to use the query where clause for advanced data filtering. Opens in new tab the on edit comes in.<br>3:15 We're going to have variable row equals e dot range Master the concept of ranges to manipulate data in Google Sheets. Opens in new tab dot get row. We're going to say variable call or column e dot range Master the concept of ranges to manipulate data in Google Sheets. Opens in new tab dot get column.<br>3:29 And the variable file name is equal to e dot value, whatever we're typing in. And if row is great. Then one.<br>3:38 Double ampersand for and. Column is equal to one. Meaning we're in that first columns.

Wherever your column is that you're putting the name in.<br>3:47 Put the number Get tips on working with numbers effectively in your spreadsheets. Opens in new tab of the column there. And if both of those are true. Then we're going to do spreadsheet Dive into the fundamentals of Google Sheets and its features. Opens in new tab app dot get active sheet Understand how to reference the active sheet in your Google Sheets. Opens in new tab dot get.<br>4:01 It range Master the concept of ranges to manipulate data in Google Sheets. Opens in new tab . It's going to be the row. And the column plus one. So wherever you want to put the actual URL.<br>4:08 Just figure out where Learn how to use the query where clause for advanced data filtering. Opens in new tab that is in relation to that column that you're on. And then end parentheses set value. And we're going to run the function Understand the basics of functions in Google Sheets for better calculations. Opens in new tab get URL with the file name.<br>4:21 This file name. Or e.value.

Now there's probably going to be one extra thing we need to add here which is if there is no file name.<br>4:37 Then we're just going to return. Blank. So that means just if there's none. Stop and just return. Literally nothing. We could also file or log, uh, any errors we might try here so let's try and, uh, clearly brackets.<br>4:58 Let's try all of this. And this is a nice way to not get errors all the time or just to log the error Get insights on common Google Sheets errors and how to fix them. Opens in new tab .<br>5:06 And we're going to catch in parentheses error Get insights on common Google Sheets errors and how to fix them. Opens in new tab . And we're just going to log or dot log. The error Get insights on common Google Sheets errors and how to fix them. Opens in new tab dot message.<br>5:16 And we'll also return non-found.

Let's save all of this. And this onEdit, let's go over here and start typing Google Sheets Templates Explore various templates to streamline your Google Sheets projects. Opens in new tab .<br>5:32 We get non-found but I know that there is URL so. Something's up. Let's go see what it is and remember we logged this error Get insights on common Google Sheets errors and how to fix them. Opens in new tab message.<br>5:42 Let's go back to our executions. Says completed. It's refresh. They're specified permissions are not sufficient to call drive.

So what this means is we have to give it permissions.<br>6:09 Well, I'm gonna skip ahead a little bit because we could run this, give it permissions, and it's still not going to work.<br>6:15 We must do one crazy thing, which is we need to not use a simple trigger Learn about simple triggers and their limitations in Google Apps Script. Opens in new tab here. We need- to name this something.<br>6:28 We'll call it, have file name, get URL, and this e we're going to keep. But we're just gonna save this as this function Understand the basics of functions in Google Sheets for better calculations. Opens in new tab , have file name, get URL, and over on the left side we're gonna go over to triggers.<br>6:44 Go on the bottom right, add trigger Explore different types of triggers available in Google Apps Script. Opens in new tab . And we're gonna choose have file name.

Get URL as the function Understand the basics of functions in Google Sheets for better calculations. Opens in new tab we're gonna run from spreadsheet Dive into the fundamentals of Google Sheets and its features. Opens in new tab and on edit.<br>6:53 What's different about this? It's an installable trigger Discover how installable triggers can enhance your Google Apps Script. Opens in new tab . So when we hit save, it's gonna ask us to authorize. And it's gonna give us the ability to have more authorizations.<br>7:04 Even though this looks and feels exactly the same as if you just ran it in your console, gave it the permissions.<br>7:11 The simple trigger Learn about simple triggers and their limitations in Google Apps Script. Opens in new tab versus the- installable trigger Discover how installable triggers can enhance your Google Apps Script. Opens in new tab . The simple trigger Learn about simple triggers and their limitations in Google Apps Script. Opens in new tab doesn't have all the permissions. The installable trigger Discover how installable triggers can enhance your Google Apps Script. Opens in new tab does. Or more.<br>7:22 So now we've installed that trigger Explore different types of triggers available in Google Apps Script. Opens in new tab on edit.

Let's go back to our sheet, go to the next row. And I'm gonna just type the same thing, Google Sheets Templates Explore various templates to streamline your Google Sheets projects. Opens in new tab .<br>7:33 And what is the answer? It's going to be a- Him Actual URL. Done for us. Automatic. All we have to do is enter the name of our Google Drive file.<br>7:44 And we get that URL. So over in our App Script Get started with Google Apps Script to automate your Google Sheets tasks. Opens in new tab , let's go back and review a little bit. We've used a normal function Understand the basics of functions in Google Sheets for better calculations. Opens in new tab , not the on edit one.<br>7:55 We've created two functions Learn about various functions to enhance your Google Sheets capabilities. Opens in new tab here, right? We get the URL with the file, which is fairly simple.

It's just these three lines here.<br>8:00 We've- Hated a little complicated with our- if there's none, return, try to give us an error Get insights on common Google Sheets errors and how to fix them. Opens in new tab message. If there's an error Get insights on common Google Sheets errors and how to fix them. Opens in new tab .<br>8:09 But it's really those three lines. Drive app.get files by name. Use the file name. Files.next. File.get URL. Done. And we're just doing it when we are editing the right column.<br>8:24 And the right cells Understand how to manipulate and reference cells in Google Sheets. Opens in new tab . pounds. 8 There we go. Hope you enjoyed that one. I hope you enjoyed that little work around of getting a URL when you enter a Google Drive file in a cool sheet.</div>

Courses

Sheet Stories / Video Notes + ADDED: Email Notifications

00:00:00

Fast FAQS

Enter Google Drive File Name Get URL

ChatGPT Clone in Google Sheets Part 2

Create an Internal Google Sheets Add-on

Tweet From a Sheet

Why Different Cell References in AI Integration in Sheets?

Show Sheet Tabs Based on Edit

Add Title Case to Google Sheets

How to Power Testimonials with Google Forms and Sheets

Getting Started Coding in Apps Script

Seek Errors When Coding Apps Script

Think Like a Programmer: Develop The Mindset of an Apps Script Coder

ChatGPT Clone in Google Sheets Part 1

Embed a Number in a Website from a Google Sheet

Create Navigation Like A Book or Presentation

Add Click Tracking To Your Google Sheets | Bitly in a Google Sheet

00:29:08

Hold a Giveaway Raffle in a Google Sheet

Quickstart Tutorial OpenAI API in Google Sheets

Capture Emails from Website Form to a Google Sheet (Without Zapier)

Embed a Headline in a Website from Google Sheets

Create a new Spreadsheet from just a Name in a Sheet.

00:05:21

Bjarne Asks: Can I show the Last Time of the Last Edit in a sheet?

00:05:43

Email Yourself a Cell from a Google Sheet, Every Day

OpenSea Data Inside Sheets

Create an Email Campaign Stats Calculator

00:35:13

Twitter App Clone in a Google Sheet

Dylan Asks: How to Automatically Delete Rows If Cell Contains Value

Highlight Row as You Move Your Cell Selection

Create a Timer with Apps Script

LinkTree in a Google Sheet

00:11:22

Password Protecting Data In a Google Sheet

Automatic Weekly Backup of Google Sheets

Create a CPM Custom Function (Create Better Calculators!)

Move Entire Row when a Cell is changed to "Yes" - The $75,000 Google Script

00:12:29

What Can You Automate in Google Sheets? Every single trigger available to Google Sheet users

Sync Two Tabs Without ImportRange()

Google Sheets Stories? No! But we'll add timestamped video notes to your google sheets.

00:00:00

Password Protecting Data In a Google Sheet Part 2 The Basics

Benoit Asks: How to Convert Case

00:07:35

Learn to Code in Google Sheets, For Programmers

Add a Checkbox to Turn on Dark Mode

00:05:10

Write Your First Script

00:08:31

Find Keywords in Any Column. Create quick search dropdown to find keywords

00:09:37

Basic CRM - Add a Powerful Script To Move Row Based on Status

How To Improve: 1,000 Business ideas: Business Idea Generator

00:11:20

Let's Make a Bookmarklet!

00:12:37

Troubleshooting Bitly in a Google Sheet Script

00:07:07

Unique Features - Design a Better Dashboard Part 2

00:04:13

How To Set Up Stripe Webhook to Google Sheets with Google Script

00:22:10

How to Edit a Macro

00:08:22

Sheet Stories / Video Notes + Clear 24 Hour Old Videos

00:35:10

Add A Timestamp to Task Lists (without Now Formula)

00:07:44

Make your Custom Functions Like Native Functions | Custom Function Autocomplete

00:17:58

Create a Changelog Between 2 Cells Custom Function | To learn Double For Loop

00:23:26

New Syntax for WhatChanged Formula in Google Script

00:07:14

How to Record Macros

00:06:20

2 Ways to Delete Lines Quickly (CAREFUL, it's a script!)

00:09:53

Deep Inside Dark Habits Google Script

00:18:54

How to Trigger Macros Daily

00:06:58

5 Ways to Create Coupon Codes | Create UUIDs

Create a Radio Button From Checkboxes Using Google Apps Script

00:15:01