peacemaker
04-03-2009, 10:02 AM
I am attempting to delete an open workbook by copying VBA code into a new workbook that upon opening, closes the original workbook ("E-Sub Slip.xls"), deletes it, and then closes the new workbook without saving.
In order to accomplish this I have a hidden worksheet (called "DontOpen") in the original workbook that has the following text:
Private Sub Worksheet_Activate()
Set wbk = Workbooks("E-Sub Slip.xls")
wbk.Activate
ActiveWindow.Close (False)
response = MsgBox("Delete E-Sub Slip.xls on C:\ drive?", vbYesNo, "")
If response = vbYes Then
On Error Resume Next
Kill "C:\E-Sub Slip.xls"
On Error GoTo 0
Else:
End If
ActiveWindow.Close (False)
End Sub
the original document used this code to execute the above:
Sheets("DontOpen").Visible = True
Sheets("DontOpen").Copy
So far I am successful in running the code but the "wkb.Activate" and the "ActiveWindow.Close (false)" code does nothing (not even an error)
What do I need to do differently for this to work?
Thanks,
peacemaker
In order to accomplish this I have a hidden worksheet (called "DontOpen") in the original workbook that has the following text:
Private Sub Worksheet_Activate()
Set wbk = Workbooks("E-Sub Slip.xls")
wbk.Activate
ActiveWindow.Close (False)
response = MsgBox("Delete E-Sub Slip.xls on C:\ drive?", vbYesNo, "")
If response = vbYes Then
On Error Resume Next
Kill "C:\E-Sub Slip.xls"
On Error GoTo 0
Else:
End If
ActiveWindow.Close (False)
End Sub
the original document used this code to execute the above:
Sheets("DontOpen").Visible = True
Sheets("DontOpen").Copy
So far I am successful in running the code but the "wkb.Activate" and the "ActiveWindow.Close (false)" code does nothing (not even an error)
What do I need to do differently for this to work?
Thanks,
peacemaker