Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: Macro Cannot Open a File That Has No Extension


View products that this article applies to.

This article was previously published under Q213785

↑ Back to the top


Symptoms

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

↑ Back to the top


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").

↑ Back to the top


Resolution

A Microsoft Visual Basic for Applications macro in Microsoft Excel 2000 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.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


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 folder. The following extensions are recognized by Microsoft Excel 2000:
   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.

↑ Back to the top


Keywords: KB213785, kbprogramming, kbpending, kbbug

↑ Back to the top

Article Info
Article ID : 213785
Revision : 6
Created on : 10/11/2006
Published on : 10/11/2006
Exists online : False
Views : 238