Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("文件路径") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets("Sheet1") Ws.Protect("123456",True,True,True) Wb.Save App.Quit
解锁
Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("文件路径") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets("Sheet1") Ws.Unprotect("123456") Wb.Save App.Quit