VBA Kill statement Error 13 Type mismatch in 2016 x64

Sephaerius

New Member
Joined
May 30, 2013
Messages
45
I'm troubleshooting yet another 2016 issue in which I have Kill statements in VBA to delete files, which has historically worked perfectly on 2013, yet now fails in 2016, and for the life of me I cannot figure out why.
To troubleshoot I've created a new Excel file and am running this test code:

Code:
Function Test()
Kill "C:\Users\username\Desktop\New Text Document.txt"
End Function

Or

Code:
Function Test()
Dim strFile As String
strFile = "C:\Users\username\Desktop\New Text Document.txt"
Kill strFile
End Function

I have access to a virtual machine running 2013, and both functions work as expected, but when I pass the test file back to my machine running 2016, I get error 13.

I've checked the Immediate window to verify that the path String is being passed, and it is. I've added it to the Watch window and stepped through it and verified that the String is a String. I've been Googling this for a day and a half and cannot find any info on why this wouldn't be working.

Nothing is being matched here that would throw a mismatch. The only parts to this are the Kill statement, and the String. Does anyone have any thoughts as to what is happening here?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I wanted to follow up and let everyone know that the root cause of my issue is that my employer has something called CylancePROTECT on my machine. I enabled it's notifications, and upon trying to execute my macros I'm getting notified that Cylance "protected" me from it.
 
Upvote 0
I wanted to follow up and let everyone know that the root cause of my issue is that my employer has something called CylancePROTECT on my machine. I enabled it's notifications, and upon trying to execute my macros I'm getting notified that Cylance "protected" me from it.
This helped! I just tried doing a Kill statement and got the Type Mismatch error - which surprised me. Quick search and I found this thread - we're also using Cylance. No big deal on my part if the file doesn't get remove.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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