SolidWorks*Excel+VBA-文件还是得要能删啊…
- 2026-11-09 08:06:47
SolidWorks*Excel+VBA-文件还是得要能删啊…调试过程中辣鸡文件太多,不删能忍? 一撸到底,回收站都不进 
xml中局部 
已关注
关注
重播 分享 赞
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 Nextopt = MsgBox("是否确认要删除文件?", vbQuestion + vbYesNo, "不正经的机械仙人")If opt <> vbYes Then Exit SubStypeArr = 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.ActiveSheetIf myselcondi ThenFor k = 1 To SelnumberProcessBarUpdater k, Selnumber, "正在删除" & Status & ":", "共" & Selnumber & "个,第" & k & "个 ..."posn = Selarray(k)If Suffix = "" ThenDsFname = .Cells(posn, 2) & "\" & .Cells(posn, 3) & .Cells(posn, 4)ElseDsFname = .Cells(posn, 2) & "\" & .Cells(posn, 3) & SuffixEnd IfIf Dir(DsFname) = "" ThenResults = "无" & Status & "文件!"Elsefs.DeleteFile DsFnameIf Err ThenResults = Status & "删除失败!"Err.ClearElseResults = Status & "已删除!"End IfEnd If.Cells(posn, 1) = Results: Results = ""NextElseMsgBox "未选择正确行,程序结束!", vbExclamation, "不正经的机械仙人"End IfEnd WithErr.ClearSet fs = NothingApplication.StatusBar = FalseEnd Sub

<splitButton id="Split00" size="large"><button id="SWnull_DelDsFiles_model" label="删除模型" image="delmodel" onAction="myftn"/><menu id="Menu00"><button id="SWnull_DelDsFiles_slddrw" label="删除工程图" image="deldrw" onAction="myftn"/><button id="SWnull_DelDsFiles_dwg" label="删除Dwg" image="deldwg" onAction="myftn"/><button id="SWnull_DelDsFiles_pdf" label="删除PDF" image="delpdf" onAction="myftn"/></menu></splitButton>

本文来自网友投稿或网络内容,如有侵犯您的权益请联系我们删除,联系邮箱:wyl860211@qq.com 。