Get our FREE VBA eBook of the 30 most useful Excel VBA macros.

Automate Excel so that you can save time and stop doing the jobs a trained monkey could do.

Claim your free eBook


Get data from OneDrive Personal files with Power Query

I shared how to get data from OneDrive or SharePoint into Power Query in a previous post. Many people noted that the method shown in that post works with OneDrive for Business but doesn’t work with OneDrive Personal. So, in this post, I will demonstrate the technique needed to connect Power Query to files in OneDrive Personal.

Watch the video


Watch the video on YouTube.

NOTES:

  • There is not an official OneDrive Personal connector from Microsoft. The method in this post uses a standard web approach which may not be optimal for your scenario.
  • While it is possible to connect to a folder in OneDrive for Business, there is no way (to my knowledge) to connect to a folder within OneDrive personal. 

Find the URL

To access files stored in the cloud on OneDrive Personal, we require a web connector in Power Query. Therefore, finding the correct URL is critical to getting this method to work.

Follow these steps:

  • Navigate to the file in OneDrive
  • Click on the three dots next to the file name, select Embed from the menu
    OneDrive Personal - Embed Link
  • A pane will open requesting if you wish to generate the HTML. Click the Generate button
    Generate HTML Code v2
  • Copy the generated code and paste it into Excel, Word, or Notepad, as we need to edit it.
  • The generated code looks like this:
    <iframe src="https://onedrive.live.com/embed?cid=F802C05E130E74FE& resid=F802C05E130E74FE%xxxxxx&authkey=xxxxxxxxxxxxxxx&em=2" width="402" height="346" frameborder="0" scrolling="no"></iframe>

    Now let’s edit this code. Remove the start, end, and cid code.

    <iframe src="https://onedrive.live.com/embed?cid=F802C05E130E74FE& resid=F802C05E130E74FE%xxxxxx&authkey=xxxxxxxxxxxxxxx&em=2" width="402" height="346" frameborder="0" scrolling="no"></iframe>

    The remaining code looks like this:

    https://onedrive.live.com/embed?resid=F802C05E130E74FE%xxxxxx &authkey=xxxxxxxxxxxxxxx&em=2

    Replace the word embed with download. The final URL looks like this:

    https://onedrive.live.com/download?resid=F802C05E130E74FE%xxxxxx&authkey=xxxxxxxxxxxxxxx&em=2
  • Copy the URL to the clipboard

Connect to the file in Power Query

Now it’s time to get the data into Excel/Power Query.

  • In Excel, click Data > From Web (or the alternative is Data > Get Data > From Other Sources > From Web).
  • Paste the URL into the URL box.
  • Click OK.
    Get Data from Web in Power Query

As the authentication key is included in the URL, you will not need to sign in.

Ta-dah! You are now connected to the file on OneDrive or SharePoint.

A little warning

In OneDrive, when you created the HTML code, did you see the warning message:

Warning message when creating HTML

“Note: Anyone who visits the blog or webpage with this embedded file will be able to view it without signing in.”

The HTML code created includes an authentication key; therefore, it is not necessary for anybody to sign in to view the file. The file is shared with anybody who has the URL. So, while this method works for getting data from OneDrive Personal, I would not recommend it for highly sensitive data that should not be viewed by others.

Conclusion

Just like connecting to OneDrive for business, OneDrive personal also requires a bit of URL trickery to identify the correct files. I wish Microsoft would make this straightforward and obvious to users. Until then, at least you know this other method. 👍

Related Posts:


Headshot Round

About the author

Hey, I’m Mark, and I run Excel Off The Grid.

My parents tell me that at the age of 7 I declared I was going to become a qualified accountant. I was either psychic or had no imagination, as that is exactly what happened. However, it wasn't until I was 35 that my journey really began.

In 2015, I started a new job, for which I was regularly working after 10pm. As a result, I rarely saw my children during the week. So, I started searching for the secrets to automating Excel. I discovered that by building a small number of simple tools, I could combine them together in different ways to automate nearly all my regular tasks. This meant I could work less hours (and I got pay raises!). Today, I teach these techniques to other professionals in our training program so they too can spend less time at work (and more time with their children and doing the things they love).


Do you need help adapting this post to your needs?

I'm guessing the examples in this post don't exactly match your situation. We all use Excel differently, so it's impossible to write a post that will meet everybody's needs. By taking the time to understand the techniques and principles in this post (and elsewhere on this site), you should be able to adapt it to your needs.

But, if you're still struggling you should:

  1. Read other blogs, or watch YouTube videos on the same topic. You will benefit much more by discovering your own solutions.
  2. Ask the 'Excel Ninja' in your office. It's amazing what things other people know.
  3. Ask a question in a forum like Mr Excel, or the Microsoft Answers Community. Remember, the people on these forums are generally giving their time for free. So take care to craft your question, make sure it's clear and concise.  List all the things you've tried, and provide screenshots, code segments and example workbooks.
  4. Use Excel Rescue, who are my consultancy partner. They help by providing solutions to smaller Excel problems.

What next?
Don't go yet, there is plenty more to learn on Excel Off The Grid.  Check out the latest posts:

Leave a Reply

Your email address will not be published. Required fields are marked *