VBAlocking了我的工作表

我试着复制一些在线代码,我发现从下面链接… http://www.ozgrid.com/forum/showthread.php?t=15325

而我试图使用一些代码来通过我的Excel工作簿中的button导入图像,这个代码locking了我的工作表,当它提示input密码,我尝试击中input没有盛行…

我在下面使用的代码

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 

请帮忙! 我把这个电子表格做了很多工作,我不能编辑任何东西:(

ActiveSheet.Protect True, True, True, True, True的第一个参数是ActiveSheet.Protect True, True, True, True, True是密码,所以你已经设置了密码True 。 (注意:不是"True" ,实际值为True ,您将不能从标准的取消保护对话框中input)。

您可以通过执行命令再次解除保护

 ActiveSheet.Unprotect True 

从即时窗口(或者你可以写一个小的子去做)。