locked
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

    Thanks,

    Zav

    Friday, September 30, 2016 12:52 AM

Answers

  • Have you "Shared" the workbook? See following link re sharing workbook.

    Share a workbook


    Regards, OssieMac

    • Marked as answer by zaveri cc Friday, September 30, 2016 5:17 PM
    Friday, September 30, 2016 1:38 AM

All replies

  • Have you "Shared" the workbook? See following link re sharing workbook.

    Share a workbook


    Regards, OssieMac

    • Marked as answer by zaveri cc Friday, September 30, 2016 5:17 PM
    Friday, September 30, 2016 1:38 AM
  • It works. Thanks.
    • Edited by zaveri cc Friday, September 30, 2016 5:17 PM
    Friday, September 30, 2016 2:16 PM