Sub DelDsFiles(DsFtype As String) '删除文件Dim DsFname As String, k As Integer, posn As LongDim Delfs As Boolean, opt As ByteDim StypeArr(), MsgArr(), SuffixArr(), ResultsArr()Dim Status As String, Suffix As String, Results As StringDim fs As ObjectOn Error Resume Next opt = MsgBox("是否确认要删除文件?", vbQuestion + vbYesNo, "不正经的机械仙人") If opt <> vbYes Then Exit Sub StypeArr = Array("model", "slddrw", "dwg", "pdf") SuffixArr = Array("", ".slddrw", ".dwg", ".pdf") ResultsArr = Array("SW模型", "工程图", "dwg", "pdf") Status = ResultsArr(WorksheetFunction.Match(DsFtype, StypeArr, 0) - 1) Suffix = SuffixArr(WorksheetFunction.Match(DsFtype, StypeArr, 0) - 1) Set fs = CreateObject("Scripting.FileSystemObject") With ThisWorkbook.ActiveSheet If myselcondi Then For k = 1 To Selnumber ProcessBarUpdater k, Selnumber, "正在删除" & Status & ":", "共" & Selnumber & "个,第" & k & "个 ..." posn = Selarray(k) If Suffix = "" Then DsFname = .Cells(posn, 2) & "\" & .Cells(posn, 3) & .Cells(posn, 4) Else DsFname = .Cells(posn, 2) & "\" & .Cells(posn, 3) & Suffix End If If Dir(DsFname) = "" Then Results = "无" & Status & "文件!" Else fs.DeleteFile DsFname If Err Then Results = Status & "删除失败!" Err.Clear Else Results = Status & "已删除!" End If End If .Cells(posn, 1) = Results: Results = "" Next Else MsgBox "未选择正确行,程序结束!", vbExclamation, "不正经的机械仙人" End If End With Err.Clear Set fs = Nothing Application.StatusBar = FalseEnd Sub