+ Reply to Thread
Results 1 to 7 of 7

Workaround for updating Files in One drive if open on another PC

Hybrid View

  1. #1
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Workaround for updating Files in One drive if open on another PC

    Hi All

    I have 2 files in a one drive folder...Main & Sub

    One person is continuously working on Main on PC1.

    On opening Sub by another person on PC2, Sub Opens Main takes info from Main and opens a listbox with that info...
    When clicking on the row in listbox, info appears in textbox.
    Textbox gets edited and processed...Code updates Main and Sub closes and saves both.
    Problem now is Main if it was closed would be updated but because it was open...when it finally closes, another version of Main is created.

    Is there any way of overcoming this...I tried setting Main as a shared file but somehow does not allow such a setting as the file contains Tables.

    How can I get the main to be updated as my code runs from Sub???
    Is there a way for real time updates??
    I am in a predicament and do not know how to overcome this...
    Is there a way of checking if the file is open in one drive on this other pc???
    Last edited by Sintek; 05-05-2018 at 06:42 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Workaround for updating Files in One drive if open on another PC

    3 hours in and I still can't find a solution...Anyone out there perhaps solved this prior...

    CODE TO TEST IF FILE IS OPEN AND THEN LOOP UNTIL AVAILABLE OR A MESSAGE PERHAPS...
    Last edited by Sintek; 05-05-2018 at 12:53 PM.

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Workaround for updating Files in One drive if open on another PC

    How bout if I put these files on network drive and add code to first test if main is open...Will that solve my problem???

    This is what I would normally make use of if the files were on one pc...Is there a way to check if file is open in one drive by changing path???
    Option Explicit
    Public wb1 As Workbook, wb2 As Workbook, wb3 As Workbook
    
    Sub Auto_Open()
    Set wb1 = ThisWorkbook
    If IsFileOpen(ThisWorkbook.Path & "\" & "Overberg Solution.xlsm") Then
        MsgBox "FILE IS IN USE", vbInformation, ""
        Call Close_Me
        Exit sub
    Else
        Application.Workbooks.Open (ThisWorkbook.Path & "\" & "Overberg Solution.xlsm")
    End If
    End Sub
    
    Sub Close_Me()
    ThisWorkbook.Save
    Application.Quit
    Application.ActiveWindow.Close savechanges:=False
    ActiveWorkbook.Close savechanges:=True
    End Sub
    
    Function IsFileOpen(filename As String)
    Dim filenum As Integer, errnum As Integer
    On Error Resume Next
    filenum = FreeFile()
    Open filename For Input Lock Read As #filenum
    Close filenum
    errnum = Err
    On Error GoTo 0
    Select Case errnum
        Case 0
        IsFileOpen = False
        Case 70
        IsFileOpen = True
        Case Else
        Error errnum
    End Select
    End Function
    Last edited by Sintek; 05-06-2018 at 09:13 AM.

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Workaround for updating Files in One drive if open on another PC

    Ok chalking this one up to as unsolved...
    Excel has limitations lol...

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,014

    Re: Workaround for updating Files in One drive if open on another PC

    As it is unsolved, I will remove the solved tag. You may get a response at some point.

    Presumably, you have investigated the share options in OneDrive? If it's corporate, then your OneDrive may be Sharepoint, in which case collaborative working should be enabled. Not sure how this affects VBA, though.
    Last edited by AliGW; 05-08-2018 at 01:10 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Workaround for updating Files in One drive if open on another PC

    Alrighty then AliGW...

    Here's to hoping lol...

    Edit...
    If it's corporate, then your OneDrive may be Sharepoint,
    Have not looked into this option...Tx will do some research.

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Workaround for updating Files in One drive if open on another PC

    Guys...I think ultimately I just need to have code to check if the specific file is is open directly in OneDrive
    Is there a way to check if file is open in one drive by changing path???
    What could the path possibly be...

+ 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. Can't find and open files on a Sharepoint drive
    By p24leclerc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2015, 10:09 PM
  2. [SOLVED] Open Network drive without mappping the drive
    By AravJ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-05-2012, 03:14 AM
  3. Replies: 0
    Last Post: 03-15-2012, 04:13 PM
  4. Replies: 0
    Last Post: 07-12-2011, 11:30 AM
  5. [SOLVED] Drive Erased, got Files back but only excel files scrambled, help.
    By Shawnky in forum Excel General
    Replies: 0
    Last Post: 05-08-2006, 02:30 PM
  6. Macro to open files isn't updating correctly
    By telewats in forum Excel General
    Replies: 2
    Last Post: 02-21-2006, 05:04 PM
  7. Can I move files From Drive to drive using VBA
    By Jeff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-18-2005, 10:06 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