Sub Divide()
Dim fPath As String
Dim fName As String
Dim wb As Workbook
Dim ws As Worksheet
Dim pwd As String
pwd = "can" ' Put your password here
'Setup
Application.ScreenUpdating = False
fPath = "C:\Documents and Settings\TRSECCAN\2011\Excel\" 'remember final \ in this string
fName = Dir(fPath & "*.xls") 'start a list of filenames
Do While Len(fName) > 0
Set wb = Workbooks.Open(fPath & fName) 'open found file
With ActiveSheet
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Locked = False
.Protect Password:=pwd
End With
wb.Close True 'close/save
fName = Dir 'get next filename
Loop
Application.ScreenUpdating = True
End Sub
我需要打开所有的工作簿的文件夹中,然后为每个表将选择的空白单元格宏,然后让他们解锁然后保护工作表与给定密码。宏在文件夹保护所有非空白单元格的xls
上面的代码只对活动的sheett执行此操作,我怎样才能使它为宏打开的所有表格?并有反正我可以提前部署下方到代码
UpdateLinks:=xlUpdateLinksNever
感谢
感谢您的输入,请检查下面的代码 – user768199