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