Re: Navigate To And Delete Workbook Vb Code
Quote from Dave Hawley;380843Code Display MoreSub KillWb() Dim wb As Workbook Dim strBookPathName As String 'Close workbook if open On Error Resume Next Set wb = Workbooks("Book1.xls") On Error GoTo 0 If Not wb Is Nothing Then strBookPathName = wb.FullName wb.Close False Else strBookPathName = "Your file path and name" End If Kill strBookPathName End Sub
Through the magic of the internet I came across this code which looks like it would work perfectly, but doesn't. Since this I"m now using Excel 2016 something must have changed in the VBA coding language. Here's the error message I'm getting:
I still have the workbook open. The code neither closes the workbook, nor deletes the file, but the error states 'File not found'. Any ideas?
Thanks in advance!
Cheers!