如何删除宏?
我有很多个EXCEL文件,里面都有宏代码
如果一个一个删除宏的话很麻烦~~
请问怎么样才能批量将这些文件的宏删除?
如放在同个文件夹然后用VBA处理...
[解决办法]
Sub ttt()
curpath = "E:\excel "
FileDir curpath
End Sub
Public Function FileDir(ByVal Path$)
Dim vDirName As String
Dim LastDir As String
Dim FullName As String
If Right(Path$, 1) <> "\ " Then Path$ = Path$ & "\ "
vDirName = Dir(Path$, 55)
Do While Not vDirName = " "
If vDirName <> ". " And vDirName <> ".. " Then
FullName = Path$ & vDirName
If (GetAttr(FullName) And vbDirectory) = vbDirectory Then
LastDir = vDirName
Call FileDir(FullName)
vDirName = Dir(Path$, 55)
Do Until vDirName = LastDir Or vDirName = " "
vDirName = Dir(, 55)
Loop
If vDirName = " " Then Exit Do
Else
CancelMacro FullName
End If
End If
vDirName = Dir(, 55)
Loop
End Function
Function CancelMacro(FileName As String)
Dim Wk As Workbook
Set Wk = GetObject(FileName)
Wk.Sheets.Copy
Wk.Close savechanges:=False
Set Wk = Nothing
Application.DisplayAlerts = False
Call ActiveWorkbook.Close(True, FileName)
Application.DisplayAlerts = True
End Function