我尝试复制一些从下面的链接中找到的在线代码......
http://www.ozgrid.com/forum/showthread.php?t=15325
我尝试使用一些代码通过我的 Excel 工作簿中的按钮导入图像,并且此代码锁定了我的工作表,当它提示输入密码时,我尝试按 Enter 键,但没有优先...
我在下面使用的代码
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
的第一个参数|是密码,所以您已将密码设置为 True
. (注意:不是 "True"
,实际值 True
,您将无法从标准的取消保护对话框中输入。)。
您可以通过执行命令再次取消保护它
ActiveSheet.Unprotect True
从即时窗口(或者你可以写一个小的 Sub 来做)。
关于VBA 锁定了我的工作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46084117/