- '批量删除EXCEL文件里的程序部分
- '引用:Microsoft Visual Basic for Applications Extensibility 5.3
- '宏安全性里勾选"信任对于"Visual Basic项目"的访问(V)"
- Private Sub CommandButton1_Click()
- On Error Resume Next
- Set fso = CreateObject("Scripting.FileSystemObject")
- fname = ActiveWorkbook.Path & "/xls"
- Set fd = fso.getfolder(fname)
- Set fls = fd.Files
- For Each fl In fls
- Set wb = Workbooks.Open(fname & "/" & fl.Name)
- With Application.VBE.ActiveVBProject
- For i = .VBComponents.Count To 1 Step -1
- LCount = .VBComponents(i).CodeModule.CountOfLines
- .VBComponents(i).CodeModule.DeleteLines 1, LCount
- .VBComponents.Remove .VBComponents(i)
- Next i
- End With
- wb.Save
- wb.Close
- Next
- MsgBox "DONE!"
- End Sub
03-23
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交