+ Reply to Thread
Results 1 to 5 of 5

VBA to Access a OneDrive file as a data source

  1. #1
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    VBA to Access a OneDrive file as a data source

    I know that this question has been asked several thousand times. I've only read 15 of them this morning.

    Most of the answers involve SHAREPOINT. What does onedrive have to do with sharepoint. I do not have a business account, so I do not have sharepoint.

    Has anyone actually done this from a microsoft 365 home account?

    The information is NOT proprietary. Here is a link anyone can open in a browser: https://1drv.ms/x/s!Ago3hUKUPQQ8gaI6...rA47w?e=xmZVlJ.

    Mu client wants to be able to use the application from any of his devices. I'll give him a "front end" on the device and I want to use this sheet as a data source.

    Ideally I would like to download this data directly, but if I can copy it locally and then use that file as the data source, I'm OK with that. I will also have to write the data back after he updates the information. I can simply let the onedrive update do that.

    Too bad onedrive doesn't allow VBA. The problem would be solved.

    The third option is to download a copy to the local drive. The only issue with this is that I have to depend on him downloading it to the proper folder. Is there anyway to automate this?

    I will take any advice people have on this issue. I'm not committed to any particular solution.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: VBA to Access a OneDrive file as a data source

    Quote Originally Posted by dflak View Post
    What does onedrive have to do with sharepoint.
    SharePoint files are often (always?) stored in OneDrive folders so can be accessed through OneDrive if you have the path.

    Too bad onedrive doesn't allow VBA.
    I don't understand what you mean by that. OneDrive is just a cloud file storage system and is agnostic about what applications or languages you use to access the files on it. OneDrive stores files on a server, and you create a OneDrive folder on your local drive that replicates files between your local drive and the server. You can definitely use VBA on them. The only problem I have had is that if you use VBA to open a file using the locally mapped OneDrive folder, and then you try to query the path of that file with ThisWorkbook.Path, you will get the URL of the server location rather than your locally mapped folder. (Dropbox has a similar operations concept but does not have this problem. I haven't tried it with Google Drive.)
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,505

    Re: VBA to Access a OneDrive file as a data source

    You could refer to a web url if you have access to the file. You have to make sure that you use the correct path.
    Open your Excel file in desktop -- > File --> Info --> Copy Path (somewhere on top as button)

    If you put that in a workbooks.open .....
    Last edited by JEC.; 08-04-2023 at 12:08 PM.

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: VBA to Access a OneDrive file as a data source

    I tired using workbooks.open and I get prompted to enter my password. When I do nothing happens.

    My url looks like https://1drv.ms/x/s!Ago3hUKUPQQ8o1vt...kCpbe?e=of9XfH

    The URLs on all the other "answers" I looked at look like "https://xxx-my.sharepoint.com/personal/Sidxxx/Documents/test.xlsx"

    Even though they are answering a question about onedrive, they all have a URL to sharepoint.

    So my question is, how do I get the correct URL? When I say copy link I get one like the one I showed.

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: VBA to Access a OneDrive file as a data source

    I modified some code I found and it does download (or creates) a file in the target directory. But any file I download seems to have the wrong file extension.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. One week data is missing from excel file stored in onedrive
    By md.ha.um.yu in forum Excel General
    Replies: 0
    Last Post: 11-14-2021, 08:59 PM
  2. [SOLVED] Saving a file to onedrive shared network and access via onedrive online
    By Sintek in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-09-2021, 11:56 AM
  3. Replies: 1
    Last Post: 09-01-2020, 03:26 AM
  4. Power Pivot attempt to source from OneDrive folder fail
    By maupiedra1979 in forum Excel General
    Replies: 0
    Last Post: 01-14-2020, 12:08 PM
  5. Replies: 5
    Last Post: 11-06-2019, 07:40 PM
  6. Replies: 6
    Last Post: 03-18-2019, 02:02 PM
  7. Replies: 0
    Last Post: 03-20-2014, 10:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1