"Cannot use this command on a protected sheet"
HELP!
I have a bit of code that runs under a button but produces an error once the Excel worksheet is protected. I need to protect most of the elements on the sheet once published, but would like to retain the functionality of the button code.
The code allows a user to select and insert a picture into a cell on the worksheet. The code is as follows...
Private Sub CommandButton1_Click()
Range("A6").Select
Dim PicLocation As String
PicLocation = Application.GetSaveAsFilename("C:\Windows\My Documents", "Image Files (*.jpg),*.jpg", , "Specify Image Location")
If PicLocation <> "" Then
ActiveSheet.Pictures.Insert(PicLocation).Select
Else
Exit Sub
End If
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Width = 235#
Selection.ShapeRange.Height = 165#
With Selection
.Placement = xlMoveAndSize
.PrintObject = True
End With
Range("D17").Select
End Sub
Is there a way to achieve the same effectandprotect the locked cells of the sheet?

