none
"Run-time error '1004' - Microsoft Excel cannot access the file" RRS feed

  • Question

  • Hi all,

    I am working within an old file that is not mine and receiving the Run-time error aforementioned (1004). 

    The line that pings for the error is:

    Workbooks.OpenText Filename:="F:\Budget\MRF\Business Team\SLM\Current\SLMUSD.xlsm"

    The file exists (the file path is correct), I can open it, and have tried running the macro while the file is active. I have also tried flipping between "OpenText" and just "Open," as I am not familiar with "OpenText." 

    I must be missing something or just being ignorant, can I get some help? 

    Thanks, 

    Monday, November 26, 2018 4:29 PM

Answers

  • Hi,

    Turns out that my Drive mapping was using a universal usercode vs. the specific server name.  I was using the correct filename, path, and code. 

    I appreciate all the help - I have seen a few unresolved Run-time 1004 errors out there; hopefully this at least helps out with one of those or gives a potential solution going forward.  

    Thanks again! 

    • Marked as answer by Gunkep Wednesday, November 28, 2018 10:39 PM
    Wednesday, November 28, 2018 10:39 PM

All replies

  • try :

    Sub test()

      Workbooks.Open Filename:="F:\Budget\MRF\Business Team\SLM\Current\SLMUSD.xlsm"

    end sub

    Monday, November 26, 2018 5:57 PM
  • That was one of the first things I tried, but nothing changed.  Same error message.  
    Monday, November 26, 2018 7:20 PM
  • Hi Gunkep,

    Please try the following code:

    Sub Consolidate()
    Path = "\\Source-Path\"
    Filename = Dir(Path & "*.xlsx")
      Do While Filename <> ""
      Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
         For Each Sheet In ActiveWorkbook.Sheets
         Sheet.Copy After:=ThisWorkbook.Sheets(1)
      Next Sheet
         Workbooks(Filename).Close
         Filename = Dir()
      Loop
    End Sub

    For more information, please see the following links:

    Run-time Error 1004: Microsoft Excel cannot access the file

    Run-time error '1004': cannot access the file

    Hopefully it helps you.

    Best Regards,

    Lina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Tuesday, November 27, 2018 3:03 AM
  • maybe your file is corrupted? try >

    Workbooks.Open Filename:="C:\Users\JOAO\Desktop\aluguel.xlsx", CorruptLoad:= xlRepairFile

    or

    Workbooks.Open Filename:="C:\Users\JOAO\Desktop\aluguel.xlsx", CorruptLoad:= xlExtractData

    the first code i send works here... so the problem is not the code but the file your trying to open ,

    maybe the file or the folder is not letting you access it. you should try moving the file to your desktop or try to use the same code in some diferente files and see it works, the error is saying that the file can not be found.

    Tuesday, November 27, 2018 10:45 AM
  • Hi,

    Turns out that my Drive mapping was using a universal usercode vs. the specific server name.  I was using the correct filename, path, and code. 

    I appreciate all the help - I have seen a few unresolved Run-time 1004 errors out there; hopefully this at least helps out with one of those or gives a potential solution going forward.  

    Thanks again! 

    • Marked as answer by Gunkep Wednesday, November 28, 2018 10:39 PM
    Wednesday, November 28, 2018 10:39 PM