Short routine appears to be stopping?

EssKayKay

Active Member
Joined
Jan 5, 2003
Messages
363
Office Version
  1. 2007
Platform
  1. Windows
Hello,

I have a short routine where I wish to -
1. Open a workbook
2. Close a window
3. Delete a file

The routine appears to be stopping after #2. I can run each on off the operations 1,2,3 separately via command buttons and it work fine. Any suggestions?

VBA Code:
Public Sub Repair_NO()
On Error Resume Next
   Workbooks.Open("" & Range("T5") & Range("V6") & "").RunAutoMacros Which:=xlAutoOpen
   Windows("Amort_Temp.xlsb").Close savechanges:=False
   Kill ActiveWorkbook.Path & Application.PathSeparator & "Amort_Temp.xlsb"
End Sub

Thanks for viewing,
Steve
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I believe I found a work around. Not the answer but it appears to be working.

I tried to run the last portion of my code (deleting temp files) that was not being triggered to now be triggered via a Private Sub Workbook_BeforeClose(Cancel As Boolean) routine. However, it still did not work.

After hour(s) of testing I think I found it. There is one routine being called from my Auto__Open Sub that sets the Application.EnableEvents = False. I changed it to True at the end of my Auto__Open sub. I then placed my “Kill” command in the BeforeClose sub and all appears to be working fine. I have a bit more testing to do but I think I’m getting close.

This is not what I really wanted. The problem (no biggie) is the “Kill” process (i.e., delete TempFile) is being run every time the worksheet is closed. I’d rather have a way to only run the this when triggered via another routine.
 
Upvote 0

Forum statistics

Threads
1,221,544
Messages
6,160,428
Members
451,645
Latest member
androidmj

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top