+ Reply to Thread
Results 1 to 5 of 5

SharePoint Online: Open latest version of Excel-file (if exists)

  1. #1
    Registered User
    Join Date
    08-23-2022
    Location
    Bonn, Germany
    MS-Off Ver
    M365
    Posts
    3

    SharePoint Online: Open latest version of Excel-file (if exists)

    Dear community,

    I'm standing in front of a very mysterious behaviour of my Excel-macro, that worked well for five years with SharePoint 2013 and SharePoint 2016, where we used to open several xlsm-files from a folder structure via WebDAV, collected some relevant data and arranged this information in a new Excel spreadsheet.

    Now, our IT migrated to SharePoint Online. WebDAV ist not available any more and I modified the VBA code to open the file using the url. On a first look this works, files are opened and data is written into my report.

    Now the mystery (for me):

    When I rename one of the Excel file or move it to another folder the macro used to tell me "file not found" (triggering further investigations by a person in charge). However, since SharePoint Online the (original) filename is somehow (!!!) opened, data is collected and transferred to my report, although the original file(name) isn't in the folder at all. This is bad, since we have to rely on getting data only of "one and only" (well named) file.

    My attempts to solve the problem so far:
    • I let IT switch off versioning in SPO (what for some reason was possible only by an SPO-admin script)
    • I implemented a sub clearing the cache of InternetExplorer
    • I deleted my RECENT folder
    • I deleted the content of my C:\Users\[USER]\AppData\Local\Microsoft\Office\16.0\Wef

    Nothing helped. When the file is deleted it is properly reported as "file not found". Only renaming or moving causes my mystery-report. Note, sync to OneDrive is not a preferred action since the VBA-code is in an Excel-AddIn used by several colleagues...

    Has someone any idea for the reason of this behaviour and a way to force Excel / SharePoint Online to get only the actual folder content?

    Many thanks in advance and kind regards,
    Alfa
    Last edited by Alfageejo; 08-25-2022 at 10:44 AM. Reason: Update: Solved

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

    Re: SharePoint Online: Open latest version of Excel-file (if exists)

    One thing with sharepoint is that it could take a while before the files are moved or renamed. Especially when multiple people are working in the file, simultaneously.

    If you did not already try, you should move it when no one is working in the file, wait for like 10 minutes and try again.
    Another tip for using sharepoint is to use Power Query instead of macro's for data transferring/transformations.

  3. #3
    Registered User
    Join Date
    08-23-2022
    Location
    Bonn, Germany
    MS-Off Ver
    M365
    Posts
    3

    Re: SharePoint Online: Open latest version of Excel-file (if exists)

    Hi JEC.

    Thanks for your comment. What I forgot to write (and it does'nt make it better, I guess) is, that currently I'm the only user of the new SharePoint Online site :-)

    Migration was done by IT and until I say that everything is fine, our old SharePoint is still live for our daily work (that's my "fall back position" for the next say 1-2 months). However, maintenance will surely be limited in time....

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

    Re: SharePoint Online: Open latest version of Excel-file (if exists)

    It is a weird problem. Especially that it puts data in a non existing file... I encountered some sharepoint issues but not like this. Maybe because it's in a test environment or something.
    How do you open the workbook in your code?

  5. #5
    Registered User
    Join Date
    08-23-2022
    Location
    Bonn, Germany
    MS-Off Ver
    M365
    Posts
    3

    Re: SharePoint Online: Open latest version of Excel-file (if exists)

    Oh, JEC. I think you gave me a decisive hint in your comments! Provided further testing maybe the solution....

    Up to now (leading to the problem) I opened the workbook like

    Please Login or Register  to view this content.
    Now I tried this (based on your Power Query hint]:

    I recorded a macro when setting up a Power Query connection to an (existing) file. Then I changed the target file name in the recorded code to a file that should not be found due to renaming. Of course this led to a Power Query error. Holding the mouse to the data connections bar displayed the yellow error message. In that message, the URL of the file (which was not found) was composed like this:

    Please Login or Register  to view this content.
    .

    Note, since I'm a newbie in this forum I'm not allowed to post links, so [TEXT] stands for the beginning of the URL (that works).

    Adding the "_api/web/getfilebyserverrelativeurl"-stuff to my report macro seems to give the expected results:
    • Exact filename is there = File is opened
    • Exact filename is not there (for whatever reason) = error message

    I'll do a bunch of tests now and of course let you know if my heart has survived the day...

    Many thanks!


    Update: The REST API reference with "getfilebyserverrelativeurl" works properly and throws error messages when expected.
    Last edited by Alfageejo; 08-25-2022 at 10:44 AM. Reason: Update

+ 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. Replies: 0
    Last Post: 03-23-2021, 05:04 PM
  2. Replies: 0
    Last Post: 07-17-2020, 11:49 PM
  3. Opening latest version of a .txt file in Excel using VBA
    By lloydie8 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-07-2017, 06:04 AM
  4. [SOLVED] Open latest version of Word file from Excel
    By sandy1977 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2017, 02:16 PM
  5. VBA -> Open Latest Version of a File [After Read-Only Save]
    By BravesPiano5 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-26-2015, 05:53 PM
  6. Macro to get the latest file (excel file) from sharepoint sites
    By vigneshwaran in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-13-2012, 09:45 AM
  7. How can I convert Excel 95 file to latest version?
    By dealrocker in forum Excel General
    Replies: 1
    Last Post: 07-03-2009, 05:57 AM

Tags for this Thread

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