Microsoft KB Archive/107904

= Microsoft Knowledge Base =

Excel: GET.DOCUMENT Macro Error with Numbered Filenames
Last reviewed: June 30, 1997

Article ID: Q107904

The information in this article applies to:


 * Microsoft Excel for Windows, versions 4.0, 4.0a
 * Microsoft Excel for the Macintosh, version 4.0

SUMMARY

When you concatenate the result from the macro command GET.DOCUMENT(1) within a SELECT statement to select a range on an active sheet, you will receive a macro error if the GET.DOCUMENT(1) statement returns a filename beginning with a number.

Steps to Reproduce Problem
  Enter the following in a macro sheet. A1: Numname_macro A2: =SELECT(INDIRECT(GET.DOCUMENT(1)&"!A1:B2",TRUE)) A3: =RETURN  Select cell A1 and choose Formula and Define Name. Define the macro as a command macro. Save a new worksheet as 1043.XLS. Activate the new sheet and run the above macro by choosing Run from the Macro menu and selecting Numname_macro.

A macro error will occur at macro cell A2.

To fix the above macro command, make these changes: insert quotation mark, apostrophe, quotation mark, ampersand after the second open parenthesis; add apostrophe before the exclamation point. The modified code should now match the line below.

=SELECT(INDIRECT("'"&GET.DOCUMENT(1)&"'!A1:B2",TRUE)) =RETURN