Access 2000 VBA - Dir() Bad File Name Or Number

I have a scenario where a user who is not on the domain is trying to open a file that is on the network. Trying to determine if the path exists using the Dir() function. Here is what my code looks like...

If Len(Dir("\\xx\xxxxx\Shared\Virtual Machine\_Testing\Update\", vbDirectory)) > 0 Then Return True

I get the Run-Time error Bad file name or number (error number 52).

Yep, dir() on a bad/inaccessible unc causes a runtime error, unlike the behaviour for a local file.

You can either wrap it in an error handler or use the GetFileAttributes API and look for the directory attribute flag (the built in getattr() won't work for this).

Hello, The code below checks if a folder exist in a sharepoint site and I am getting "Bad file name or number" on the following code: If Len(Dir("//

For the time-being, if the user doesn't mind mapping a network drive, he could open the file with your code the way it is.

Join Date 01-27-2010 Location Tysons Corner, VA, USA MS-Off Ver Pro 2019 Posts 16,132

Access 2000 VBA - Dir() Bad File Name Or Number. Ask Question Asked 8 years, 7 months ago. Active 7 months ago. Match partial folder name in Access VBA. 2.

Remove the invalid path. Use Windows Explorer to locate the network SysData directory.Open the System.CFG file in Notepad or Wordpad.Look for a section with a header of [SysData].If FRx Report Server is installed and running in your environment:a.

It looks liks strSavedDir already includes a filename, since it ends in .xls plus a backslash \. Is. C:\Users\abc\Desktop\Equity (L0)V2.xls\ really the correct folder path?

DIR is a very special function in VBA, its job is to return a string representing the name of a file, directory, or an archive that matches a specified pattern. DIR function only returns the first file name or folder name from a location that matches the specified attributes.