Unlock image-object automatically

Mötley

Board Regular
Joined
Aug 3, 2011
Messages
93
Hi everyone,

I really need a help with this. I have protected worksheet, I'm able to insert images into sheet but image itself is locked, so I can't resize etc it. Is it possible that inserted image automatically unlocks itself??

This is the code I'm using to insert images:

Code:
Sub InsertPic()
ActiveSheet.Unprotect
    Dim myPicture As String
    myPicture = Application.GetOpenFilename _
                ("Pictures (*.gif; *.jpg; *.bmp; *.tif),*.gif; *.jpg; *.bmp; *.tif", _
                 , "Select Folder to Import")
    If myPicture = "False" Then Exit Sub
    myPicture = Left(myPicture, InStrRev(myPicture, "\"))
    InsertAllPix Range("A50"), _
                 myPicture, _
                 "*.jpg"
ActiveSheet.Protect
End Sub
Code:
Sub InsertAllPix(r As Range, ByVal sDir As String, sFilt As String)
ActiveSheet.Unprotect
    Dim **** As String
    Dim iRow As Long
 
    If Right(sDir, 1) <> "\" Then sDir = sDir & "\"
    **** = Dir(sDir & sFilt)
 
    Do While Len(****)
        iRow = iRow + 1
        With ActiveSheet.Pictures.Insert(sDir & ****)
            .ShapeRange.LockAspectRatio = msoFalse
            .Height = r(iRow, 1).Height
            .Width = r(iRow, 1).Width
            .Top = r(iRow, 1).Top
            .Left = r(iRow, 1).Left
            .Placement = xlMoveAndSize
        End With
        **** = Dir
    Loop
ActiveSheet.Protect
End Sub
 
Last edited:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
When I do "Insert --> picture", then I'm able to resize image, even when protected but not when using code above. What's the problem?
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,916
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top