How to Retrieve the Pathname of FileLast reviewed: November 2, 1994Article ID: Q59774 |
The information in this article applies to:
SUMMARYThe DIRECTORY() command can be used in a Microsoft Excel macro to retrieve the drive/directory pathname of the current directory. In Microsoft Excel, any time the directory is changed from any source, the directory pointer will be changed to reflect the last drive and/or directory selected. The directory pointer is changed even if you choose Cancel (press ESC) in the dialog box (custom or built-in). Note: The DIRECTORY() command returns only the most recent drive and directory selected, so that a progression through various directories cannot be followed, nor can multiple directories be selected unless you choose OK (press ENTER) between selections and the macro calls the dialog box for each new directory to be selected. In a Microsoft Excel macro, the DIRECTORY() command can be used after the DIALOG.BOX() command to retrieve the current directory that has been changed by a custom dialog box. Example: =DIALOG.BOX(dialog_ref) =DIRECTORY() Another technique, useful when you open files, is to use the GET.DOCUMENT(2) command, which returns the directory of the active document. After an OPEN() operation, the active document is the document just opened, so that GET.DOCUMENT(2) returns the active drive/directory. These steps can also be used in Microsoft Excel version 5.0 by using the macros from version 4.0 in a macro sheet.
|
KBCategory: kbusage
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |