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.

Excel Academy

Excel Academy
The complete program for saving time by automating Excel.

Excel Automation Secrets

Excel Automation Secrets
Discover the 7-step framework for automating Excel.

Office Scripts Course

Office Scripts: Automate Excel Everywhere
Start using Office Scripts and Power Automate to automate Excel in new ways.

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

Leave a Comment