+ Reply to Thread
Results 1 to 8 of 8

Is it possible to read a file from share point directory in a macro?

  1. #1
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Is it possible to read a file from share point directory in a macro?

    I found this post on this site: https://www.excelforum.com/excel-pro...nt-folder.html

    But doesn't help, I'm working on a template that will eventually reside within Teams and seems all files are saves to a sharepoint folder.

    Yesterday I setup and got working a Power Automation flow that monitors my inbox for a email from our requests server, when that email arrives, the flow gets triggered and the attachment in that email is saved to a specific folder within our teams (sharepoint path) this works great and was pretty quick and simple to setup.

    Now comes my template, my current macro works if i run it against a local folder, it picks up the file, copies the data into the template and does its work..
    I'm trying to merely change where that file is "read"/"opened" from.

    Even if this template is not saved in TEAMS, the macro still needs to work off the file in teams as its source.

    For testing purposes, I'm running the following macro:

    Please Login or Register  to view this content.
    And there is no file to upload as I'm not getting past getting to a file to process.. so the above macro is in a blank file. If you place a breakpoint on the While Filename <> "" line, the error will appear on the line above it.
    If you find the suggestion or solution helpful, please consider adding reputation to the post.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: Is it possible to read a file from share point directory in a macro?

    The DIR function will not work. You would need to map the sharepoint folder to a drive first.

    As you know the name of the workbook you could write a function that users error trapping to detect the failure to open the workbook.
    Simplest way to get the correct filepath is to manually open a file within the sharepoint folder and then use this code in the intermediate window

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Is it possible to read a file from share point directory in a macro?

    Can a drive be mapped within the macro so that it can be used, then unmapped once the macro is completed?

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,437

    Re: Is it possible to read a file from share point directory in a macro?

    Yes. 1 result from google
    https://www.access-programmers.co.uk...ac2007.268572/

    But as I mentioned in your case you know the folder and file so only need to open it, and use error handling if not present.

  5. #5
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Is it possible to read a file from share point directory in a macro?

    Thanks for the link i had already viewed and tested those examples, thats why i had made my post. All the functions work to get the mapped drives and paths but the map function never worked using either the
    https://xxxxxxxx.sharepoint.com or the unc \\xxxxxxxx.sharepoint.com

    Im testing it this morning, but are you saying i should be able to just call Workbooks.Open ("https://xxxxxxxx.sharepoint.com") and as long as i have the proper error handling that should work for what i need to do? No need to map a drive?

  6. #6
    Registered User
    Join Date
    07-11-2021
    Location
    the UK
    MS-Off Ver
    2019
    Posts
    7

    Re: Is it possible to read a file from share point directory in a macro?

    Yes, you can do workbook.open directly with a sharepoint link.
    What you also can consider - is adding the SharePoint folder to your OneDrive - in that case you're 'sharepoint' files become local via your onedrive and that one you can operate with as usual network file.

  7. #7
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Is it possible to read a file from share point directory in a macro?

    well if it was only me working within sharepoint i would, but im building a template for a whole department and each person has their own folder / file that they need to use to populate the template. So looking for as much automation as possible.

  8. #8
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Is it possible to read a file from share point directory in a macro?

    I finally tested and it worked and was as simple as this:

    Please Login or Register  to view this content.
    It was able to open and return the value in A1 for my test, so now im working on incorporating it into my macro and adding the error handling
    Thank you for the suggestions.

+ 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. Importing .csv file data from share point to html
    By KermitPannell in forum Excel General
    Replies: 0
    Last Post: 10-08-2019, 10:48 AM
  2. Replies: 1
    Last Post: 09-09-2015, 11:10 AM
  3. To transfer .ocd file from one excel to another for export of share-point data.
    By vinay8657 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-13-2014, 09:57 AM
  4. Share document as a read-only file with the ability to update
    By Fresh-Young-Cheese in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-04-2012, 09:28 PM
  5. macro to read names of subfolders in a directory
    By michael.steffensen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-05-2012, 09:21 AM
  6. how to open a non-standard named file from share point
    By sankar kasilingam in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 08-30-2012, 07:33 AM
  7. File Not Found in correct directory, but able to read file name
    By googlebot in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-29-2008, 06:50 PM

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