Create Google Form Automatically

Learn how to automate the creation of Google Forms directly from Google Sheets with just a few clicks. This video guides you through building a custom menu using Google Apps Script, making it easy to share templates with others.

if we're building templates or even trying to give some kind of sheet to someone else, and we want forms around this, it's quite simple just to go up to tools, create a new form. But what that's gonna do is create a Google form in our drive. And then connect it to the sheet. And so when we share this sheet, the other person needs to create that Google form all over again. So what I'm gonna show you in this video is how to automate that in just a couple clicks and give yourself a nice little menu inside of your sheet so that when you share this template , either sell it or give it to other people, either clients or even your colleagues to use. They can create a Google form very simply with just a couple clicks. So let's go to Extension's app script and start building this out. The very first thing I want to do is create a menu up here.

So I'm gonna go to bedsheets doco slash snippets and get this code here. This is just an unopened code and I'm gonna paste it here. And all I wanna do is call this create form, and I'm gonna create one item called create form. I'm gonna call this form menu. I can even delete this line and this second item I can delete as well. So we just have one item. It says, function on open. Get the UI functions from the spreadsheet . Create a menu, call it form menu, add one item called Create Form, and then it's gonna run a function called create form. Let's go and create that function now. So the very first thing we wanna do is actually create the form. So we're gonna get a variable form equals. Form app dot Create and we're gonna create something called a form for this sheet, whatever you wanna name it.

We can set a description as well, a form for a sheet, whatever you wanna name it. We also need to set the destination, which is going to be our spreadsheet , get active spreadsheet , get sheet id . And before this, it takes two things. We need this form app dot destination type dot spreadsheets, all in. Sorry, spreadsheet , all in caps. This is just saying, Hey, we're gonna put the destination that is a spreadsheet and then the second item in here is going to be the ID of the spreadsheet . So if we wanna test this out right away without any other items, 'cause we will be adding some items here. Add items. These are gonna be the text items that you actually fill out. We can save this and go back to our sheet and we're gonna refresh our sheet and just

make sure that up here next to extensions, next to help is a form menu, and if I create form, I need to authorize it. We're gonna be able to use drive and sheets and continue. And if I go to my drive, I'll see I actually have the form. It has no items and the responses are not linked to a sheet. So we need to do that. So let's go back to Extensions app script . And I think one error is, we actually don't need the sheet id . We just need the ID of the spreadsheet . So let's run this again. And now we have linked our destination. There we go. And again, we'd have no items yet, but we will fix that. So let me unlink this form, unlink and delete, and let's go back to our app script and start adding some items. We want form dot. Add text item, do set title. Let's get a name and let's see what else we need.

Name and email address, form, add, text item, set, title, email. I'm gonna set validation here. So we're gonna say email validation and we're gonna create a variable email validation equals form app dot create text validation . Require text is email and build. Now, this is a validation that says the text must be an email. We're going to insert that validation there for email. We can also say service interest variable or sorry, form dot add text item, set title, service interest. Now this could be a text item or it could be a multiple choice item.

Let's actually add a multiple choice item here, and we need a set choice values , and this is going to be a, an array, so we're gonna need square brackets, and here we can add these items. Podcast notes , audiogram or other, and we're going to separate it not with um, spaces, but rather commas. And then let's add one more other in single quotes. And so these choice values will be available. To the person filling out the form, and then we need one more thing, which is biggest challenge form add text item set title. It's your biggest challenge. And then we can also set a description here, which is set help text.

And that help text is the description underneath and we can give it all of this. What is your biggest challenge right now? What is your biggest challenge right now? And so we can save this and let's test it out. Let's go back to our spreadsheet , go to form menu, create form, and it's finish the script. And there we go. We have our name, email, service, interest, and biggest challenge. We can even go to this form. Tools manage form, edit form. And we can see, it's a short answer here. Short answer with the text is email validation a multiple choice question and another text question with a help text. Pretty cool, right? So now without having to have this form already created, we can actually delete

this or unlink it and delete it, and then share this as a CRM and say, Hey, anytime you wanna create a form, go up to form menu, create form, and the. Form will already be created for someone with these items. Pretty cool, right? If you want this specific code, go down below. I put a link to this sheet in the description. Get it for free, absolutely free. You are watching better sheets here on YouTube. Make sure you check out this video or this video and subscribe right now to get more tips, tricks, how tos, get more out of your Google sheets than you ever have before. I'm excited to be making a ton more videos here. Ask me questions down in the comments and I will answer them in future videos. But for right now, right here, one of these videos is gonna

be your next Google sheet.