VBA to List files and folder in Google Drive Office

VBA to List files and folder in Google Drive Office So let me first run this at the moment basically starting the drive service and this is saying uh using the drive service.

Uh run this function list files and folders and it's saying maximum size uh you know like uh items to be returned in one page is hundred.

And then i want to bring you know um only one page okay load one page so i'm gonna run this now return me all the files in that particular uh.

In the particular user drive so these are all the ids the names parent id create the time or the fade time so there are more attributes now uh the size meme type uh you can query.

Using all this information and then on by me and here it should be there should be some shared files so these are shared files so it's owned by.

Me is false shared it true and then as you can see here and if there are any file in trash then you'll be able to see here this is the web content link which you can.

VBA to List files and folder in Google Drive

Directly share uh you know it will automatically download the file if you open this link so for example.

If you go here uh this is because there are multiple accounts located here in this particular uh chrome that's why i'm not able to access but.

If you only have one account then it you should automatically download and then this is the file to you know like uh to view okay and then if there are any description it.

Should pull the information here so for example um let me add a description this is a sample description okay so if i refresh this now it says.

This is some sample description okay so it will pull that information as well like i said in the beginning uh earlier we only had like a default of.

100 uh in a free version but here there is no limit as such you can bring in as much as possible uh at the moment i don't have.

    Enough file here to demonstrate that but

    Um so let's say that i put in lots of examples here for example if you have like.

    Let's say that 4000 files uh you can specify about 900 to 1000 here to be in one page and then you can specify four piece five piece and so on so you can once the you know like it.

    Will keep uh gathering all the files needed to display in uh pulling back here for you so uh for example if you specify 900 here.

    And then you run this it will bring you know like up to 900 in one page it will try to uh gather that in that data and then it will.

    Do it at least for four times as long as it returns the data it's gonna go forward for multiple pages okay and then once it brings that information it's gonna you know like check if there.

    Is data if it is it's going to clear this data and then these are the headers it just prints the headings.

    Okay and then this part is basically uh printing the headers this is the array of all the strings and then this part is basically uh transposing the array that has been.

    Returned here and then printing it to uh a2 range e2 okay again if you want to look through each item you can use this.

    Alternate method here as well so for example if i remove this and run this now it'll print all the information here as well so in case you're not using xlu.

    Let's say that you're trying this in

    Access database uh you can print this information and populate this maybe in a trivia in in your database tables.

    Okay now more examples on excuse me uh on using the query uh so if you go to this page there will be lots of examples that you can utilize.

    So these are all the you know like how you want to query uh the files in google drive okay so let me demonstrate some of them first is this in parent so um.

    Let's say that you want to pull in all the files in a folder so for example in a data folder and then we have we have data folder we have.

    Expense data we have documents and then others so let's say that we want to bring in all the files in this particular folder only you can specify.

    Uh you can use this query okay so i'm saying can bring in all the files uh where this particular id is the parent.

    Okay so um i'm gonna disable this this is the query execution example um saying that the max based page size is going to be hundred and then total base to.

    Query is this one and then query example okay so similarly like if you have more files that you're expecting to return you can specify more here um i'm gonna run this now and then now.

    As you can see these are all in the same pair and these are the files in that folder okay um let's try another example now if you want to bring in a specific.

    Name type file type by this you can query as well um if you want to uh try is querying you know like specific email id you can also do that.

    Yeah so these are two files where this particular email id user id has a write access to the file okay so it can be useful and this one you can.

    Directly find if there is any files which is shared with me and maybe the name is this yeah so it will return you the data if it is available.

    Share with me and the name contains this so apparently there's no file like this let me let me try another example in fact let me.

    So again this is the same example um you can also query by modify time just remember that this is all based on utc uh time zone so just be mindful of that.

    If you want to find you know a file specific to the name uh you can directly use this so for example earlier i was trying to find a baby course.

    This one uh you can specify the name is equal to this so lookup id uh function uses this query basically where you know you specify a name and.

    Then it pulls the id you know using this table information so let's try this so it returned two files with the same uh.

    With the same name okay um and then and then this one here you can filter out by mean type and then basically example of where you can query two two types.

    Uh where the meme type is the folder and then it's located in trash okay so that will be pretty much uh on the listing all the files and folders if you.

    Have any questions again please comment or reach out to me and then this is example of you know more information about this particular function.

    And this one is again using this particular function which says list files and folders this is all these files and folders so when we call the lookup object id.

    By name uh it you pass the name of the file and then this query basically you know like try to find a file so if there are more than.

    One file with the same name then it says that there are more than one file so if you have to you know like query uh by applying a better filter this is where you're gonna come and.

    DISCLAIMER: In this description contains affiliate links, which means that if you click on one of the product links, I'll receive a small commission. This helps support the channel and allows us to continue to make videos like this. All Content Responsibility lies with the Channel Producer. For Download, see The Author's channel. The content of this Post was transcribed from the Channel: https://www.youtube.com/watch?v=QZUfmSzjDa0
Previous Post Next Post