Reputation: 1104
I tried copying some code online that I found from below link... http://www.ozgrid.com/forum/showthread.php?t=15325
And I attempted to use some code to import an image via button within my Excel Workbook and this code locked my work sheet and when it prompts for a password I tried hitting enter with no prevail...
Code I used below
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
Please help! I put a lot of work into this spread sheet and I can't edit anything :(
Upvotes: 1
Views: 116
Reputation: 23974
The first parameter of ActiveSheet.Protect True, True, True, True, True
is the password, so you have set the password to be True
. (Note: not "True"
, the actual value True
, which you won't be able to type in from the standard unprotect dialog.).
You can unprotect it again by executing the command
ActiveSheet.Unprotect True
from the Immediate Window (or you could write a small Sub to do it).
Upvotes: 5