0

I'm getting an error message (Run-Time error 1004: Method Open of object Workbooks failed) in VBA when trying to open files with long path names

FileToOpen = "\\serverName\[long path > 260 characters long]\ExcelFile.xls
Workbooks.Open Filename:=FileToOpen

I tried adding \?\UNC\ but I have the same error message

FileToOpen = "\\?\UNC\serverName\[long path > 260 characters long]\ExcelFile.xls
Workbooks.Open Filename:=FileToOpen

Is there a way around to open long paths in VBA?

Selrac
  • 2,203
  • 9
  • 41
  • 84
  • See [this post of May 20](https://excel.uservoice.com/forums/304921-excel-for-windows-desktop-application/suggestions/10733559-increase-the-218-character-filename-length-limit-t) from someone on the Microsoft Excel team. Seems like you may be running into an OS limit. But there is a registry hack to get around that for Windows. Maybe try it and see if it works for VBA (or power query or other methods of opening files from Excel). – Ron Rosenfeld Dec 13 '20 at 20:21
  • I think that hack is only for Windows 10; not earlier versions. – Ron Rosenfeld Dec 13 '20 at 21:02
  • 1
    Similar question [here](https://stackoverflow.com/a/38541415/9808063) .. may be helpful .... or if ... you can create a hidden shortcut on a shorter path and open it in VBA – Naresh Dec 14 '20 at 09:29

0 Answers0