Deleting an Excel File via Macro Action (1 Viewer)

Huskergirl

Registered User.
Local time
Yesterday, 23:17
Joined
Apr 24, 2013
Messages
12
I'm wondering if it is possible to delete an existing Excel file via a Macro (in Access 2007) Action and, if so, how?

Thanks in Advance!

Sara
 

Huskergirl

Registered User.
Local time
Yesterday, 23:17
Joined
Apr 24, 2013
Messages
12
Thanks - After more digging, I realized I could do it via a module:

Sub RunExcelMacro()
Dim xl As Object
'Step 1: Start Excel, then open the target workbook.
Set xl = CreateObject("Excel.Application")
xl.Workbooks.Open ("C:\Documents and Settings\nel58556\My Documents\Net Improvement Report\CM NEW RPS - PM AT RISK.xlsm")
'Step 2: Make Excel visible
xl.Visible = False
'Step 3: Run the target macro
xl.Run "DeleteWorksheets"
xl.Run "DeleteFiles"
'Step 4: Close and save the workbook, then close Excel
xl.ActiveWorkbook.Close (True)
xl.Quit
'Step 5: Memory Clean up.
Set xl = Nothing
End Sub

Appreciate the feedback though!

Have a good day.

Sara
 

Users who are viewing this thread

Top Bottom