我正在尝试删除当前打开的excel文件。我没有特定的名称,所以必须这样
Kill .FullName
当我这样做时:
Dim relativePath As String
relativePath = "\\FILES\" & Format(Now, "yyyy-mm-dd hh_mm") & " - " & ActiveWorkbook.Name
ActiveWorkbook.SaveAs Filename:=relativePath
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"C:\PROGRAM.csv", FileFormat:=xlCSV _
, CreateBackup:=False, Local:=True
On Error Resume Next
With ActiveWorkbook
.Saved = True
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
On Error GoTo 0
Application.DisplayAlerts = True
它不会仅删除保存的PROGRAM.csv
我的初始文件
任何人都可以帮我删除我最初打开的文件吗?
答案 0 :(得分:0)
首次SaveAs
之前,在originalName = ActiveWorkbook.FullName
原始文件之后的任何地方添加一行SaveAs
然后再向下,添加Kill originalName