VBA Open file from network drive folder which is already open by another user RRS feed

  • Question

  • Hi All,

    I am using below code to open the file from a folder on a network drive. The issue is if file is opened by another user than it gives me error "Someone else is using that file. Please try again later". I just want to open the file even if it's read only because i am just copying data from that file.

    Sub LoopThroughFiles()
    Application.ScreenUpdating = False
    Set MyObj = CreateObject("Scripting.FileSystemObject")
    Set MySource = MyObj.GetFolder("Z:\Folder\")
    myarray = Array("NY", "VA", "CA")
      For Each item In myarray
        For Each file In MySource.files
            Myfile = file
        If Myfile Like "*" & item & "*" Then
            Workbooks.Open (file), ReadOnly:=True, IgnoreReadOnlyRecommended:=True, Notify:=False
            StrOpenWb = ActiveWorkbook.Name



    Friday, September 30, 2016 12:52 AM


All replies