excel file showing in use, when it is not

Answered excel file showing in use, when it is not

  • Wednesday, May 02, 2012 7:56 AM
     
     
    I openend an excel file to check if any work had been done on it - there was none, so I closed the file [without saving it] ... now the file shows that it was modified on at that time, which it should not ... and most importantly it reads that my logon has locked the file and is now only available as "read only" .... how can this be unlocked, so that it is again accessible to other users and myself .... {I have since then been logged off and closed down completely - no change in status or message}

All Replies

  • Wednesday, May 02, 2012 12:47 PM
     
     Answered Has Code

    Try to check by this VBA function:

    Function IsFileOpen(FileName As String)
    Dim iFilenum As Long
    Dim iErr As Long
         
        On Error Resume Next
        iFilenum = FreeFile()
            Open FileName For Input Lock Read As #iFilenum
            Close iFilenum
        iErr = Err
        On Error GoTo 0
         
        Select Case iErr
            Case 0:    IsFileOpen = False
            Case 70:   IsFileOpen = True
            Case Else: Error iErr
        End Select
    End Function
    
    sub test() 'run this procedure
    msgbox "Your file is open: " & IsFileOpen("c:\filePath\File.xls") '<- change your path
    end sub


    Oskar Shon, Office System MVP

    Press if Helpful; Answer when a problem solved

  • Tuesday, May 08, 2012 3:05 PM
     
     

    PetraMx are you trying this function?


    Oskar Shon, Office System MVP

    Press if Helpful; Answer when a problem solved