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.

Table of Contents

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:


Discover how you can automate your work with our Excel courses and tools.

The Excel Academy

Excel Academy

Make working late a thing of the past.

The Excel Academy is Excel training for professionals who want to save time.

3 thoughts on “Get data from OneDrive Personal files with Power Query”

  1. The solution presented in the vidoe will only work if you do the following (courtesy of Mynda Treacy of https://www.myonlinetraininghub.com/):

    1. In Onedrive, right-click the file and go to “Embed”.
    2. At the bottom of the popup, click the “Customise how this embeded workbook will appear to others”
    3. In the new browser’s tab appear, look for the “Embed Code” section, where you will find the path you need.
    4. After copying the path, this video will work perfectly.

    Codus Mynda.

    Reply

Leave a Comment