本帖最后由 long826121 于 2011-9-11 09:40 编辑
回复 opelwang 的帖子
给你做了一个!
代码如下:
Sub jiami()
Dim mypath As String, xlsname As String
Dim wbk As Workbook
mypath = ThisWorkbook.Path
xlsname = Dir(mypath & "\" & "*.xls")
Application.DisplayAlerts = False
Do While xlsname <> ""
If xlsname <> ThisWorkbook.Name Then
Set wbk = Workbooks.Open(mypath & "\" & xlsname)
wbk.Password = "123456"
wbk.Close savechanges:=True
End If
xlsname = Dir
Loop
Application.DisplayAlerts = False
End Sub
Sub jiemi()
Dim mypath As String, xlsname As String
Dim wbk As Workbook
mypath = ThisWorkbook.Path
xlsname = Dir(mypath & "\" & "*.xls")
Application.DisplayAlerts = False
Do While xlsname <> ""
If xlsname <> ThisWorkbook.Name Then
Workbooks.Open (mypath & "\" & xlsname), Password:="123456"
ActiveWorkbook.Password = ""
ActiveWorkbook.Close savechanges:=True
End If
xlsname = Dir
Loop
Application.DisplayAlerts = False
End Sub
123.rar
(36.84 KB, 下载次数: 29)