sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,404
- Office Version
- 2016
- Platform
- Windows
I'm having some real issues trying to kill a closed workbook - my routine has a main workbook and what I'm trying to achieve is the following;
1) Get the main workbook name and store it for use later
2) Save the current (main) workbook as a temporary file
3) Kill the original main workbook so I can open another (updated) workbook and save it as the original main file name
This is what I have so far:
The workbooks are stored in a network folder and there are NO permission issues as the 'temp' file is deleted without an issue in another routine later. I am getting a persistent 'Error 70 Permission Denied' on the following line:
I have tried various things to no avail - can anyone spot where the issue is?
1) Get the main workbook name and store it for use later
2) Save the current (main) workbook as a temporary file
3) Kill the original main workbook so I can open another (updated) workbook and save it as the original main file name
This is what I have so far:
VBA Code:
SavedFileName = ActiveWorkbook.Name
Application.ScreenUpdating = False
Application.EnableEvents = False
ThisWorkbook.SaveAs filename:=ThisWorkbook.Path & "\Temp.xlsm"
Application.EnableEvents = True
SetAttr ThisWorkbook.Path & "\Temp.xlsm", vbHidden
SetAttr ThisWorkbook.Path & "\" & SavedFileName, vbNormal
Kill ThisWorkbook.Path & "\" & SavedFileName
Application.ScreenUpdating = True
DoEvents
The workbooks are stored in a network folder and there are NO permission issues as the 'temp' file is deleted without an issue in another routine later. I am getting a persistent 'Error 70 Permission Denied' on the following line:
VBA Code:
Kill ThisWorkbook.Path & "\" & SavedFileName
I have tried various things to no avail - can anyone spot where the issue is?