Microsoft KB Archive/105211

= Microsoft Knowledge Base =

MXL: Can't Delete Folder Using Macro or Procedure
Last reviewed: September 12, 1996

Article ID: Q105211

The information in this article applies to:


 * Microsoft Excel for the Macintosh, versions 3.0, 4.0, 5.0

SYMPTOMS
In Microsoft Excel version 5.0, when you use the RmDir statement in a Visual Basic procedure, you may receive the following error message:

Run-time error '75':

Path/File access error In Microsoft Excel, when you use DELETE.DIRECTORY in a macro, the command may return the logical value FALSE and fail to delete the specified folder.

Additionally, when you drag a folder to the trash in the Finder while Microsoft Excel is running, you may receive the following error message when you empty the trash

The item " " could not be deleted, because it contains items that are in use. Do you want to continue? Where is the name of the folder that you are trying to delete.

CAUSES
This behavior may occur if any of the following are true:

 The folder is not empty. The folder is the current folder in Microsoft Excel (the default folder that appears when you choose Open from the File menu). The folder name or path to the folder is not properly specified in the RmDir statement, or the DELETE.DIRECTORY macro command.  Microsoft Excel has created a "working directory" for the folder. A working directory is an internal name that points to the folder and prevents the folder from being deleted using the RmDir statement or the DELETE.DIRECTORY command or the Finder until you quit Microsoft Excel. A working directory to the folder can be created if one of the following occurs during the current session of Microsoft Excel: A file is manually opened, deleted, or saved to the folder. -or- A file is opened or saved to the folder via a macro. -or- The the DIRECTORY command is used to make the folder current; even if the folder is no longer the current folder, a working directory to     the folder is created. -or- The DELETE.DIRECTORY command failed previously because the folder was current. Even if you manually change to a different folder, the DELETE.DIRECTORY command will still fail. 

WORKAROUNDS
To prevent a working directory from being created, do not use the ChDir statement, or the DIRECTORY command to change to the folder. If you need to delete files from the folder, specify the path to the folder in the Kill statement, or the FILE.DELETE command.

If a working directory has been created due to one of the causes stated previously, you must quit Microsoft Excel before you can delete the folder.

Note if you delete a file in Microsoft Excel version 5.0 using the Find File dialog box, a working directory is not created, and this behavior does not occur.

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.