E có đoạn code sau:
E đang muốn hỏi cái đoạn Protect/unprotect
Khi code chay đến đoạn unprotect có hỏi pass.. nhưng khi protect lại thì chẳng hỏi j (nghĩa là có protect nhưng ko có pass). Vậy làm thế nào để protect lại vẫn có pass như lúc đầu..
.....
E có tham khảo thì đặt pass ngay sau protect, ví dụ: With Sheets("data").Unprotect("pass") .... Sheets("data").Protect("pass")
Tuy nhiên, có khúc mắc nho nhỏ:
- Như thế tính bảo mật hơi kém.. view code là nhìn thấy hết
- Khi protect e có tích chọn một số thứ trong hộp kiểm như: cho phép dùng filter/pivot table... Nếu sử dụng code:
thì sau khi code chạy xong không còn sử dụng được filter/pivot table (mà chỉ mặc định protect ở select lock cells và select unlocked cells)
E cảm ơn ạh
Mã:
[COLOR=#333333][FONT=lucida grande]...........[/FONT][/COLOR]
[COLOR=#333333][FONT=lucida grande] If ActiveWorkbook.MultiUserEditin[/FONT][/COLOR][COLOR=#333333][FONT=lucida grande]g Then ActiveWorkbook.ExclusiveAccess[/FONT][/COLOR]
[COLOR=#333333][FONT=lucida grande] With Sheets("data").Unprotect[/FONT][/COLOR]
[COLOR=#333333][FONT=lucida grande] Call VlookUp[/FONT][/COLOR][COLOR=#333333][FONT=lucida grande]
Call VlookUp2
Call VlookUp3
Sheets("data").Protect
End With
ActiveWorkbook.SaveAs FileName:=ActiveWorkbook.FullName, _
accessMode:=xlShared
.....[/FONT][/COLOR]
E đang muốn hỏi cái đoạn Protect/unprotect
Khi code chay đến đoạn unprotect có hỏi pass.. nhưng khi protect lại thì chẳng hỏi j (nghĩa là có protect nhưng ko có pass). Vậy làm thế nào để protect lại vẫn có pass như lúc đầu..
.....
E có tham khảo thì đặt pass ngay sau protect, ví dụ: With Sheets("data").Unprotect("pass") .... Sheets("data").Protect("pass")
Tuy nhiên, có khúc mắc nho nhỏ:
- Như thế tính bảo mật hơi kém.. view code là nhìn thấy hết
- Khi protect e có tích chọn một số thứ trong hộp kiểm như: cho phép dùng filter/pivot table... Nếu sử dụng code:
Mã:
[COLOR=#333333][FONT=lucida grande]If ActiveWorkbook.MultiUserEditing Then ActiveWorkbook.ExclusiveAccess[/FONT][/COLOR][COLOR=#333333][FONT=lucida grande]
[/FONT][/COLOR][COLOR=#333333][FONT=lucida grande]With Sheets("data").Unprotect("pass")
Call VLookup
Call VlookUp2
Call VlookUp3
Sheets("data").Protect ("pass")
End With
ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.FullName, _
accessMode:=xlShared[/FONT][/COLOR][COLOR=#333333][FONT=lucida grande]
[/FONT][/COLOR]
thì sau khi code chạy xong không còn sử dụng được filter/pivot table (mà chỉ mặc định protect ở select lock cells và select unlocked cells)
E cảm ơn ạh
Lần chỉnh sửa cuối: