|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
请勿用于非法途径
Sub codeDelete()
Dim sPath$, sFileName$, sFullName$
sPath = ThisWorkbook.Path & "\新建文件夹\"
sFileName = Dir(sPath & "*.xls*")
Do While sFileName <> ""
sFullName = sPath & sFileName
oneDelete sFullName
sFileName = Dir
Loop
End Sub
Sub oneDelete(sFileName As String)
Application.DisplayAlerts = False
On Error Resume Next
Dim wkBook As Workbook
Set wkBook = GetObject(sFileName)
Dim objVbc As Object
With wkBook.VBProject
For Each objVbc In .VBComponents
Select Case objVbc.Type
Case 1, 2, 3
.VBComponents.Remove .VBComponents(objVbc.Name)
Case Else
With objVbc.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next
End With
Application.Windows(wkBook.Name).Visible = True
wkBook.Close 1
End Sub |
评分
-
2
查看全部评分
-
|