Hi All,
I have a macro that inserts a picture into a worksheet. It's working perfectly in Excel 2007. The worksheet is protected, but the cells where I want to put the picture are unlocked. In 2007 it just puts them where instructed. In 2003 I get a Run-Time error 1004 "Cannot use this command on a protected sheet". When I protected the worksheet I selected the option that users can select unlocked cells and can edit objects. I'm stumped here. I need the users to be able to insert a picture, and delete it if the had selected the wrong one. Can anyone see a way around this? thanks in advance. The code is here:
I have a macro that inserts a picture into a worksheet. It's working perfectly in Excel 2007. The worksheet is protected, but the cells where I want to put the picture are unlocked. In 2007 it just puts them where instructed. In 2003 I get a Run-Time error 1004 "Cannot use this command on a protected sheet". When I protected the worksheet I selected the option that users can select unlocked cells and can edit objects. I'm stumped here. I need the users to be able to insert a picture, and delete it if the had selected the wrong one. Can anyone see a way around this? thanks in advance. The code is here:
Code:
Sub Insert_Picture()
Dim myPicture As Variant
Dim myCell As Range
myPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif; *.png),*.gif; *.jpg; *.bmp; *.tif *.png", , "Select Picture to Import")
If VarType(myPicture) = vbBoolean Then
MsgBox "Operation Cancelled"
Else
With ActiveSheet
Set myCell = .Range("B5:O30")
.Pictures.Insert(myPicture).Select
With myCell
Selection.Top = .Top
Selection.Left = .Left
Selection.Width = .Width
Selection.Height = .Height
Selection.Placement = xlMoveAndSize ' move and size with cells
Selection.PrintObject = True
'.Select
End With
End With
End If
Range("B4").Select
End Sub