|
I'm not sure why you are having problems with the KILL-command. However, I have created an example that will allow you to see how you might pull this off. Here are the steps to reproduce my example.
1. Open Excel.
2. Choose "Tools->Macro->Visual Basic Editor"
3. Right click the ThisWorkbook item and choose "View Code"
4. Add the following code:
Private Sub Workbook_Open()
Dim dialog As DeleteFileForm
Set dialog = New DeleteFileForm
dialog.Show (vbModeless)
Set dialog = Nothing
End Sub
5. Right click the Microsoft Excel Objects item and Insert a UserForm. Change its name to DeleteFileForm.
6. Right click the DeleteFileForm item and choose "View Code".
7. Add the following code:
Private Sub buttonDelete_Click()
On Local Error GoTo ErrHandler
Kill (textBox.Text)
Exit Sub
ErrHandler:
Debug.Print (Error)
End Sub
7. Right click the DeleteFileForm and choose "View Object".
8. Add a lable, textbox and button to the form. Name the textbox "textBox", and the button "buttonDelete".
9. Save the macro and Excel file to persist your changes.
10. Press the F5 key to begin debugging your macro!
|