XL97: Macro Can't Open File That has no Extension

Last reviewed: February 27, 1998
Article ID: Q157320
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

In Microsoft Excel 97, when you use a macro to open a file, the wrong file may be opened.

CAUSE

This may occur if the following conditions are true:

  • The name of the file you are trying to open has no extension. For example, it is named "Noext".

        -and-
    
  • The file you are trying to open is in the same folder as another file whose name is identical but whose name includes a recognized file extension (for example, "Noext.xls").

RESOLUTION

A Visual Basic for Applications macro in Microsoft Excel 97 cannot use the Workbooks.Open command to open a file with no extension if a file whose name is identical but contains a recognized extension exists in the same folder.

For this reason, Microsoft strongly recommends that you include an extension when you name your data files.

Microsoft also recommends that you include the file extension in the FileName argument of the Workbooks.Open command, if possible.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

In Microsoft Excel, you can use the Workbooks.Open command within a Visual Basic for Applications macro to open files. Usually, the command looks similar to the following:

   Workbooks.Open FileName:="Myfile.xls"

If you have a file whose name contains no extension, you can usually open it with the Workbooks.Open command. For example, the command would look like this:

   Workbooks.Open FileName:="Noext"

This command works correctly and opens the file "Noext", unless a file whose name is identical but includes a recognized file extension, exists in the same folderThe following extensions are recognized by Microsoft Excel 97:

   xls   txt   dbf   wk3   wk1   wq1   slk   csv   dif

If such a file exists in the same folder as the file without an extension, that file opens instead.


Additional query words: XL97
Keywords : kbprg xlvbahowto xlloadsave
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 27, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.