VBA Script to insert image
hi,
Private Sub CommandButton1_Click()
Dim fd As FileDialog
Dim ffs As FileDialogFilters
Dim Rng As Range
ActiveSheet.UnProtect "password"
Set Rng = ActiveSheet.Range("B8") ' adapt to your range
Rng.Select
Set fd = Application.FileDialog(msoFileDialogOpen)
With fd
Set ffs = .Filters
With ffs
.Clear
.Add "Pictures", "*.jpg"
End With
.AllowMultiSelect = False
If .Show = False Then Exit Sub
Fichier = fd.SelectedItems(1)
Set Pict = ActiveSheet.Pictures.Insert(Fichier)
Pict.ShapeRange.LockAspectRatio = msoFalse
Pict.Height = Rng.Height
Pict.Width = Rng.Width
End With
ActiveSheet.Protect "password", DrawingObjects:=True, Contents:=True,
Scenarios:=True
End Sub
isabelle
Le 2014-07-21 16:56, clvrbas a écrit :
isabelle;1618222 Wrote:
hi,
when you protect the sheet, you have to allow the users to edit objects
(DrawingObjects:=False)
isabelle
Le 2014-07-21 11:58, clvrbas a écrit :-
This works really great, one problem though; when I protect the sheet
it
re sizes to normal size and has an error, is there a way around that?
-
Thank you, i should have specified more clearly. I was hoping I could
only allow users to edit that particular object, and not the other
objects I have on the sheet. I'll insert this and see what I can do!
:) Thank you for your help.
-- Chris
|