ID: Q118414
5.00 WINDOWS kbfixlist
The information in this article applies to:
In Microsoft Excel, if you use the GET.DOCUMENT(1) function in a macro to return the name of the active document, for example to parse or process information in the file, you may receive a macro error if the file is in the Text, CSV, SYLK, or PRN file format.
When you open a file in one of these formats, the worksheet name is Sheet1, instead of the name of the document without the extension. This may cause a macro that uses the name returned by the GET.DOCUMENT(1) function to return a macro error.
The GET.DOCUMENT(1) function returns the name of the active sheet as text, for example, "[Book1]Sheet1." However, when the worksheet has the same name as the workbook, (minus the workbook file extension), the GET.DOCUMENT(1) function returns the name of the file, such as BOOK1.XLS. This behavior is equivalent to the behavior of the GET.DOCUMENT(1) function in Microsoft Excel version 4.0.
Note that when you open a Microsoft Excel version 4.0 Worksheet file, a Lotus 1-2-3 file, or a QuattroPro/DOS file, the worksheet has the same name as the workbook file, and therefore the GET.DOCUMENT(1) function returns the name of the file.
To avoid receiving a macro error when you use the GET.DOCUMENT(1) function in a macro to return the name of the document, do either of the following:
-or-
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel for Windows version 5.0c.
For more information about GET.DOCUMENT, choose the Search button in Microsoft Excel Macro Functions Help and type:
GET.DOCUMENT function
KBCategory: kbprb
KBSubcategory:
Additional reference words: 5.00 comma separated value print ascii symbolic link sheet name
Version : 5.00
Platform : WINDOWS
Last Reviewed: September 14, 1996