5,139
社区成员
发帖
与我相关
我的任务
分享
Sub protect()
Set xlapp = Application
Set xlBook = xlapp.Workbooks.Open("c:\textfile.xls")
Set xlSheet = xlBook.Worksheets(1)
xlapp.Visible = True
xlSheet.Unprotect Password:="123"
xlSheet.protect Password:="123" ', Scenarios:=True ', Contents:=True, UserInterfaceOnly:=True
xlSheet.EnableSelection = -4142
xlBook.Save
xlapp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
End Sub