Excel 宏从位置删除文件,然后保存到其他位置?

Excel 宏从位置删除文件,然后保存到其他位置?,excel,vba,save,Excel,Vba,Save,我创建了一个宏,用于将图纸保存到特定位置(见下文): 子Savefileas() 将ws设置为工作表 For Each ws In ActiveWorkbook.Worksheets ws.Unprotect Password:="Spiralbevel1" ws.EnableSelection = xlNoSelection ws.Protect Password:="Spiralbevel1", DrawingObjects:=False, Contents:=True, Scenarios

我创建了一个宏,用于将图纸保存到特定位置(见下文): 子Savefileas() 将ws设置为工作表

For Each ws In ActiveWorkbook.Worksheets
ws.Unprotect Password:="Spiralbevel1"
ws.EnableSelection = xlNoSelection
ws.Protect Password:="Spiralbevel1", DrawingObjects:=False, Contents:=True, Scenarios:=True
Next ws

Dim ThisFile As String
Dim varResult As Variant
ThisFile = Range("B4").Value
varResult = Application.GetSaveAsFilename(FileFilter:= _
"Macro Enabled Workbook" & "(*.xlsm), *xlsm", Title:=ThisFile & ".xlsm", InitialFileName:="G:\New Manufacturing Engineering\Gear Shop\Spiral Bevel\Miscellaneous\Stock Removal Test File\Stock Removals with Errors\ " & ThisFile & ".xlsm")
With ActiveWorkbook
    On Error GoTo message
    .SaveAs varResult & ".xlsm", FileFormat:=52
    Exit Sub
message:
    MsgBox "There is an error"
End With
End Sub
需要查看此工作表,然后使用此宏将其保存到其他位置:

Sub Savefileas()
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
ws.Unprotect Password:="Spiralbevel1"
ws.EnableSelection = xlNoSelection
ws.Protect Password:="Spiralbevel1", DrawingObjects:=True, Contents:=True, Scenarios:=True
Next ws

Dim ThisFile As String
Dim varResult As Variant
ThisFolder = Range("B2").Value
ThisFile = Range("B4").Value
varResult = Application.GetSaveAsFilename(FileFilter:= _
"Macro Enabled Workbook" & "(*.xlsm), *xlsm", Title:=ThisFolder & ThisFile & ".xlsm", InitialFileName:="G:\New Manufacturing Engineering\Gear Shop\Spiral Bevel\Miscellaneous\Stock Removal Test File\" & ThisFolder & "\ " & ThisFile & ".xlsm")
With ActiveWorkbook
    On Error GoTo message
    .SaveAs varResult & ".xlsm", FileFormat:=52
    Exit Sub
message:
    MsgBox "There is an error"
End With
End Sub
我需要做的是将原始文件从保存到的原始文件夹中删除


提前感谢

Kill
,然后是文件的完整路径和名称。这很好,但文件名将在不同的项目中更改,我是否可以使用Kill命令并将其链接到具有以下文件名的单元格:我已尝试Kill(范围(“H2”)),但它不起作用-这可能会有所帮助