+ Reply to Thread
Results 1 to 13 of 13

VBA To Check File Exists In Sharepoint

  1. #1
    Forum Contributor
    Join Date
    06-18-2007
    Location
    Kiama, Australia
    MS-Off Ver
    365
    Posts
    119

    VBA To Check File Exists In Sharepoint

    Hi Folks,

    Does anybody have some VBA code that checks if a file exists in Sharepoint?
    I thought this would be a simple task but it's proving to be quite a challenge.
    Select "Add Reputation" to thank me.

  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 Check File Exists In Sharepoint

    Do you mean that you have just a filename, but you don't know where it's located, and you want to search for it? Or do you mean that you have a file name and location and want to see if it is actually there?

    SharePoint is basically a web site and VBA does not have built-in features to search a web site. There may be an add-in or something available if you need to search.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    06-18-2007
    Location
    Kiama, Australia
    MS-Off Ver
    365
    Posts
    119

    Re: VBA To Check File Exists In Sharepoint

    I have a file name and location and want to ascertain if the file exists.

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

    Re: VBA To Check File Exists In Sharepoint

    You should go with power query

  5. #5
    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 Check File Exists In Sharepoint

    This will check if a file exists at a specific URL:

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    06-18-2007
    Location
    Kiama, Australia
    MS-Off Ver
    365
    Posts
    119

    Re: VBA To Check File Exists In Sharepoint

    Many thanks.
    I'll try this.
    Last edited by OzTrekker; 03-22-2022 at 06:34 PM.

  7. #7
    Forum Contributor
    Join Date
    06-18-2007
    Location
    Kiama, Australia
    MS-Off Ver
    365
    Posts
    119

    Re: VBA To Check File Exists In Sharepoint

    I've tried this Function and it always tells me the file exists at the URL irrespective of whether the file actually exists.
    Am I missing something?
    Is there a Reference that needs to be activated?

    My URL looks like this "https://company.sharepoint.com/sites/ESUTeamPlanning/Shared Documents/ESU Files/Costing & Reporting/NG/Invoicing/2022/STTM/202203/MSV/QEN/20220323 MSV.pdf".

  8. #8
    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 Check File Exists In Sharepoint

    There is no reference needed. I did some testing on this for files in a public web site and it worked fine for me. I wonder if there is an issue related to the fact that you have to login to the site.

  9. #9
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,543

    Re: VBA To Check File Exists In Sharepoint

    Jeff, maybe the problem is with the cache. You may need to clean it before checking it. I don't know much about it, so I just throw a thought. Or maybe I'm talking nonsense.

    Artik

  10. #10
    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 Check File Exists In Sharepoint

    Atik, possibly, but this code does not use a browser, it sends the HTTP directly. I'm not sure if VBA maintains a cache.

  11. #11
    Registered User
    Join Date
    10-11-2023
    Location
    SF
    MS-Off Ver
    O365
    Posts
    1

    Re: VBA To Check File Exists In Sharepoint

    Could you please explain how to test the coding 6StringJazzer posted? Thanks.

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,492

    Re: VBA To Check File Exists In Sharepoint

    In a worksheet cell, it should be:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  13. #13
    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 Check File Exists In Sharepoint

    Quote Originally Posted by sarante View Post
    Could you please explain how to test the coding 6StringJazzer posted? Thanks.
    Welcome to the Forum sarante!

    Normally we prefer that new questions go in a new thread (please read the rules), especially since this thread is over 18 months old. But since your question is directly about an answer posted for the OP, and not some new twist, it should be fine.

+ 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. VBA Sharepoint Check In File after Upload
    By PhatRam32 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-26-2020, 03:32 PM
  2. Check if file exists (allows users to input file path in cell)
    By plakatown in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-20-2020, 04:07 AM
  3. HOW CHECK FILE.NAME HAS EXISTS OR NOT IN FOLDER,if not exists then copy
    By daboho in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-13-2018, 03:50 AM
  4. [SOLVED] Check if file exists and if so save file incremented by 1 e.g. filename(1).xlsm
    By ratdogexcel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2014, 01:15 AM
  5. check if file exists and opening it based on file date
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-26-2014, 03:45 AM
  6. VBA code to Check if a Folder exists in SharePoint
    By shavazo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2013, 07:46 AM
  7. Check if file exists on SharePoint https environment
    By Purpose in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2013, 04:17 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