Hi, I have the following code below. When you use F8 (and select "No") to step through manually, the macro works fine. However, when you call the macro and it runs automatically (and select "No"); it results in error #70 "Permission Denied" for line 12.
Would anyone have any idea as to why that might be?
Public Function FN_RENAME_OLD_VERSION()
On Error GoTo ErrorHandler
1: Application.StatusBar = "Updating Old Version File Name"
2: Answer = MsgBox("Would you like to make the new version ''Rev +1'' from the old version?" & vbNewLine & vbNewLine & _
"Clicking ''No'' will rename the old version as ''OLD VERSION; DELETE AFTER VERIFYING ACCURACY''", vbYesNo)
'IF_1
3: If Answer = vbYes Then
'IF_1_Y
'<<<MAKE NEW VERSION ONE REV HIGHER THAN OLD VERSION>>>
4: Windows(Range("OLD_VERSION").Value).Activate
5: Range("FILE_REV").Copy
6: ThisWorkbook.Activate
7: Range("FILE_REV").PasteSpecial Paste:=xlPasteValues
8: Range("FILE_REV").Value = Range("FILE_REV").Value + 1
'IF_1_N
Else
'<<<RENAME OLD VERSION>>>
9: Windows(Range("OLD_VERSION").Value).Activate
10: ActiveWorkbook.SaveAs FileName:=ThisWorkbook.Path & "\OLD VERSION; DELETE AFTER VERIFYING ACCURACY.xlsm"
11: ThisWorkbook.Activate
'<<<DELETE ORIGINAL VERSION>>>
12: Kill ThisWorkbook.Path & "\" & Range("OLD_VERSION").Value
13: ThisWorkbook.Activate
'IF_1_E
End If
Exit Function
ErrorHandler:
FunctionError = True
Call EMAIL_ERROR("FN_RENAME_OLD_VERSION", Err.Number, Err.Description, Erl, Application.UserName, Now)
End Function
Bookmarks