Run-time Error '1004' - Method 'Open' of object 'Workbooks' failed

后端 未结 8 698
故里飘歌
故里飘歌 2021-01-21 00:09

OK, so far I\'ve uninstalled & re installed Office-2010 3 to 4 times, done hours of research for 3 days with no success. I started getting this error either from Vbscript or

相关标签:
8条回答
  • 2021-01-21 00:32

    I know I'm answering late on this, but I resolved a similar issue (same error but running excel from a .Net app) by making sure VBA was installed correctly on the target machine.

    Control Panel->Programs and Features->Uninstall a Program... find your Office install, Right-click and select "change" ->Add Remove Features->Office Shared Features->Visual Basic for Applications->Run From My Computer

    This did it for me.

    0 讨论(0)
  • I had a rogue excel process that was running in the background. When I killed it from the task manager the code worked. I hope this helps.

    0 讨论(0)
  • 2021-01-21 00:36

    The file is corrupted. Resave it with another name and change the name in the function. Try that it works and after that rename the file as you want to call it.

    It worked for me and I had a corrupted file. The read only shouldn't be a problem.

    0 讨论(0)
  • 2021-01-21 00:43

    I realise this is late but if you want to open & repair a corrupted workbook automatically use:

    Set oWB = Workbooks.Open(Filename:="C:\my\file\path.xlsx", CorruptLoad:=XlCorruptLoad.xlRepairFile)
    
    0 讨论(0)
  • 2021-01-21 00:45

    Putting an answer here for others like myself who have this issue and the normal solutions don't work.

    Another potential cause of this is corrupted temporary files. I think it may only apply if the file you are trying to open is on a network drive or other remote host.

    Anyway, try wiping your temp folder (as in the one you get to if you type %temp% into Windows Explorer) then restarting the computer.

    0 讨论(0)
  • 2021-01-21 00:45

    I was too, going crazy with Workbook.Open function, getting the weird Open fail error for no obvious reason. My code also did some some copy-pasting after Open function, which seemed to trigger it.

    Eventually I found out that turning ScreenUpdating OFF seemed to cause this - keeping ScreenUpdating ON, made things click for me (maybe someone finds this helpful in the future). I'm one of those who tends to switch ScreenUpdating off for all code whenever possible.

    Application.ScreenUpdating = False
    
    0 讨论(0)
提交回复
热议问题