我試圖複製一些代碼網上,我從以下鏈接找到... http://www.ozgrid.com/forum/showthread.php?t=15325VBA鎖定我的工作表
我嘗試使用一些代碼通過按鈕我的Excel工作簿中導入圖像,並驗證碼鎖定我的工作表,當它提示輸入密碼我試着打不佔上風進入...我用下面
Sub BrowsePicture()
Dim Pict
Dim ImgFileFormat As String
Dim PictCell As Range
Dim Ans As Integer
ActiveSheet.Protect True, True, True, True, True
ImgFileFormat = "Image Files (*.bmp),others, tif (*.tif),*.tif, jpg (*.jpg),*.jpg"
GetPict:
Pict = Application.GetOpenFilename(ImgFileFormat)
'Note you can load in any nearly file format
If Pict = False Then End
Ans = MsgBox("Open : " & Pict, vbYesNo, "Insert Picture")
If Ans = vbNo Then GoTo GetPict
'Now paste to userselected cell
GetCell:
Set PictCell = Application.InputBox("Select the cell to insert into", Type:=8)
If PictCell.Count > 1 Then MsgBox "Select ONE cell only": GoTo GetCell
PictCell.Select
ActiveSheet.Pictures.Insert(Pict).Select
End Sub
代碼請幫幫忙!我投入了大量的工作,到這個電子數據表,我不能編輯任何內容:(
根據[Microsoft文檔](https://msdn.microsoft.com/en-us/vba/excel-vba/),'ActiveSheet.Protect True,True,True,True,True'行鎖定電子表格文章/工作表保護法,EXCEL)。 [文檔](https://msdn.microsoft.com/en-us/vba/excel-vba/articles/worksheet-unprotect-method-excel)也建議'ActiveSheet.Unprotect'應該解鎖它,假設沒有密碼組。 – Afforess