tranaidh
Thành viên mới

- Tham gia
- 31/5/08
- Bài viết
- 39
- Được thích
- 0
Ý định của tôi như sau:
- lưu file excel ở ổ D: hoặc ổ E: khi sử dụng file excel này có Form hiện lên, nhập mk để sử dụng.
- Nếu nhập mật khẩu sai quá 3 lần thì nó tự động save as vào ổ dĩa C: và xóa luôn file gốc.
Ý định như thế nhưng thực hiện mới đc phần save as còn phần xóa file gốc thì chưa thực hiện đc. Mong các bạn giúp đỡ!
Private Sub CommandButton1_Click()
If Textpass = "beyeu" Then
Pass.Hide
ActiveSheet.Unprotect "123456"
Sheet1.[a1] = 0
Else
If Sheet1.[a1] > 3 Then
Pass.Hide
ActiveSheet.Unprotect "123456"
Sheet1.[a1] = 0
ActiveSheet.Protect "123456"
ThisWorkbook.SaveAs Filename:="C:\testfile.bak"
'Muon them phan xoa file goc vao day
Application.Quit
Else
Pass.Hide
ActiveSheet.Unprotect "123456"
Sheet1.[a1] = Sheet1.[a1] + 1
Pass.Textpass.SetFocus
Pass.Show
End If
End If
End Sub
- lưu file excel ở ổ D: hoặc ổ E: khi sử dụng file excel này có Form hiện lên, nhập mk để sử dụng.
- Nếu nhập mật khẩu sai quá 3 lần thì nó tự động save as vào ổ dĩa C: và xóa luôn file gốc.
Ý định như thế nhưng thực hiện mới đc phần save as còn phần xóa file gốc thì chưa thực hiện đc. Mong các bạn giúp đỡ!
Private Sub CommandButton1_Click()
If Textpass = "beyeu" Then
Pass.Hide
ActiveSheet.Unprotect "123456"
Sheet1.[a1] = 0
Else
If Sheet1.[a1] > 3 Then
Pass.Hide
ActiveSheet.Unprotect "123456"
Sheet1.[a1] = 0
ActiveSheet.Protect "123456"
ThisWorkbook.SaveAs Filename:="C:\testfile.bak"
'Muon them phan xoa file goc vao day
Application.Quit
Else
Pass.Hide
ActiveSheet.Unprotect "123456"
Sheet1.[a1] = Sheet1.[a1] + 1
Pass.Textpass.SetFocus
Pass.Show
End If
End If
End Sub