Visual Basic for Applications Reference

Bad file mode (Error 54)

See Also    Specifics

Statements used in manipulating file contents must be appropriate to the mode in which the file was opened. This error has the following causes and solutions:

  • A Put or Get statement is specifying a sequential file.

    Put and Get can only refer to files opened for Random or Binary access.

  • A Print # statement specifies a file opened for an access mode other than Output or Append.

    Use a different statement to place data in the file or reopen the file in an appropriate mode.

  • An Input # statement specifies a file opened for an access mode other than Input.

    Use a different statement to place data in the file or reopen the file in Input mode.

  • You attempted to write to a read-only file.

    Change the read/write status of the file or don't try to write to it.

For additional information, select the item in question and press F1.