|
Visual Basic (VB and VBA) |
|
Copyright 1999-2001 Christopher Greaves. All rights reserved. Home Page and email to [email protected] |
| If in doubt, record a macro and inspect the entrails! |
Please read the DISCLAIMER.
Here is an INDEX to all the procedures.
You will probably need one copy of my GLOBAL DECLARATIONS.
Public Function doQKill(strFileName As String, Optional strPrompt As String = "")
' Procedure : doQKill
' Description: Kill the file, optionally ask the user.
' Copyright: Chris Greaves Inc.
' Inputs: File/document name, Optional prompt
' Returns: Nothing
' Assumes: Nothing
' Side Effects: Will delete a file.
' Tested: By the calls shown below.
If strPrompt = "" Then
If boolDocIsOpen(strFileName) Then
Documents(strGetFilename(strFileName, 4)).Close savechanges:=wdDoNotSaveChanges
End If
If boolFileExists(strFileName) Then
On Error GoTo Failed
Kill strFileName
End If
Else
If UCase(InputBox(strPrompt, "doQKill", "Y")) = "Y" Then
If boolDocIsOpen(strFileName) Then
Documents(strGetFilename(strFileName, 4)).Close savechanges:=wdDoNotSaveChanges
End If
If boolFileExists(strFileName) Then
On Error GoTo Failed
Kill strFileName
End If
Else
End If
End If
GoTo Ended
Failed:
MsgBox "This file may be in use by another user or process: " & strFileName
Ended:
'Sub TESTdoQKill()
'Call doQKill("c:\eraseme.txt")
'Call doQKill("c:\eraseme.txt", "is this ok?")
'Call doQKill("c:\eraseme.txt")
'End Sub
End Function
| We all knew nothing when we started … |
|
Home Page and Contact Information Send email to [email protected]. This page was last updated Thursday, November 15, 2001 |