LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 124
Default kill command and excel

thank you for taking the time to respond.

"JLatham" wrote:

Well, I suppose you could use something like
Kill filetodestroy.Text

Or you might be able to make use of this code which allows you to select a
file using the file picker dialog, and in this case, Kill the file selected:

Sub KillAFile()
Dim Response As String
Response = SelectFileForUse()
If Response < "" then
Kill Response
End If
End Sub

Function SelectFileForUse() As String
'either return a full well-formed path & filename
'to file selected, or "" if user cancels.
'
Dim fd As FileDialog
Dim vrtSelectedItem As Variant

'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)

With fd
If .Show = -1 Then
'user chose a file
'Step through each string in the FileDialogSelectedItems collection.
For Each vrtSelectedItem In .SelectedItems
'vrtSelectedItem is a String that contains the path of each selected
item.
'You can use any file I/O functions that you want to work with this
path.
SelectFileForUse = vrtSelectedItem
Next vrtSelectedItem
'The user pressed Cancel.
Else
SelectFileForUse = ""
End If
End With

Set fd = Nothing ' good housekeeping
End Function

"charles" wrote:

thanks hank.
but that is not the information that i need.

I want to be able to select the file that i want destroyed from a list of
files in a drop down box. And have the kill command destroy the file that is
selected in the drop down box. The drop down box name is "filetodestroy"

"Hank Scorpio" wrote:

On Sat, 29 Aug 2009 17:35:01 -0700, charles
wrote:

I would like to use the Kill command to delete a file whose name and location
have been selected in a drop down box.

ie the drop down box named "filetodestroy" has the following selected
C:programs/mycrap/test.xls

what syntax do u use to make the kill command destroy the file selected?

It's just
Kill pathname

but at a guess your problem is that it should be
C:\programs\mycrap\test.xls

(That is, you're missing the first slash after the drive. Generally
the path will use backslashes rather than forward slashes as well,
though either will work with Kill.)

You may also want to use
On Error Resume Next
before the command and
On Error GoTo 0
after it to temporarily turn off error handling. That way if the file
isn't there, you won't be bugged with an error message.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Kill Macro Jeff Excel Discussion (Misc queries) 4 September 27th 06 04:33 PM
How do I kill the Research pane, other task panes in Excel EllenB Setting up and Configuration of Excel 2 August 9th 06 10:44 PM
On time kill Antonio Excel Discussion (Misc queries) 4 June 8th 06 10:50 AM
How to kill ALL copied pictures? johncory Excel Discussion (Misc queries) 3 November 2nd 05 06:49 PM


All times are GMT +1. The time now is 12:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"