Bad file name or number

An error occurred trying to access the specified file. Among the possible causes for this error are:

  • A statement refers to a file with a file name or number that was not specified in the FileOpen statement, or that was specified in a FileOpen statement but was subsequently closed.
  • A statement refers to a file with a number that is out of the range of file numbers.
  • A statement refers to a file name or number that is not valid.

To correct this error

  • Make sure the file name is specified in a FileOpen statement. Note that if you invoked the FileClose statement without arguments, you may have inadvertently closed all open files.
  • If your code is generating file numbers algorithmically, make sure the numbers are valid.
  • Check file names to make sure they conform to operating system conventions.

See Also

FileOpen Function | Visual Basic Naming Conventions

Show: