OFF97: Kill Statement May Delete All Files in a Folder (169093)
The information in this article applies to:
- Microsoft Office 97 for Windows
- Microsoft Excel 97 for Windows
- Microsoft Word 97 for Windows
- Microsoft Access 97
- Microsoft PowerPoint 97 for Windows
This article was previously published under Q169093 SYMPTOMS
In any of the programs listed at the beginning of this article, if you run
a Visual Basic for Applications macro that includes the Kill statement, the
macro may delete all of the files stored in a folder on a network server.
CAUSE
This behavior may occur when all of the following conditions are true:
- A drive letter is mapped to a folder on a network server.
-and-
- The network server is running Microsoft Windows NT Server, version
3.51 or 4.0, or Microsoft Windows NT Workstation, version 3.51 or 4.0.
-and-
- The current directory is the root directory of the mapped network drive.
-and-
- You use syntax for the Kill statement that is similar to either of the
following
Kill ""
-or-
Kill <FileList>
where <FileList> is a variable that refers to nothing (""), a variable
that is uninitialized, or a variable that refers to a path that does not
include a file name.
If all of the above conditions are true, all of the files in the root
directory of the mapped network drive may be deleted without warning.
RESOLUTION
Microsoft provides examples of Visual Basic for Applications procedures for
illustration only, without warranty either expressed or implied, including,
but not limited to the implied warranties of merchantability and/or fitness
for a particular purpose. The Visual Basic procedures in this article are
provided 'as is' and Microsoft does not guarantee that they can be used in
all situations. While Microsoft support professionals can help explain the
functionality of a particular macro, they will not modify these examples to
provide added functionality, nor will they help you construct macros to
meet your specific needs. If you have limited programming experience, you
may want to consult one of the Microsoft Solution Providers. Solution
Providers offer a wide range of fee-based services, including creating
custom macros. For more information about Microsoft Solution Providers,
call Microsoft Customer Information Service at (800) 426-9400.
To prevent files from being deleted by the Kill statement, verify that the
Kill statements always refer to both a valid path and a valid file name.
The following examples demonstrate the syntax to use:
Kill "\\server\share\myfiles\*.old"
Kill "E:\myfiles\*.old"
Dim FileList As String
FileList = "*.old"
Kill "\\server\share\myfiles\" & FileList
Dim FileList As String, NetPath As String
NetPath = "\\server\share\myfiles\"
FileList = "*.old"
Kill NetPath & FileList
These are all valid uses of the Kill statement.
You can also prevent this problem from occurring by making sure that there
are no drive letters that are mapped to shares on the network server. The
problem occurs only if a drive letter is mapped to the server.
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.
REFERENCES
For more information about the Kill statement, click the Office Assistant
in the Visual Basic Editor, type kill,
click Search, and then click to view "Kill Statement."
NOTE: If the Assistant is hidden, click the Office Assistant button on the
Standard toolbar. If Microsoft Help is not installed on your computer,
please see the following article in the Microsoft Knowledge Base:
120802
Office: How to Add/Remove a Single Office
Program or Component
Modification Type: | Major | Last Reviewed: | 5/23/2003 |
---|
Keywords: | kbbug kbProgramming KB169093 |
---|
|