Insert picture by using a button

MathiasA

New Member
Joined
Oct 26, 2015
Messages
8
Hi
I have a workbook that are adding rows on different pages and they all refer to each other with item numbers, description etc on items.
all sheets are locked except for some cells where different departments add in information
On one of the sheets i want to be able to insert pictures in specific cells.

i want it to that you click on the row and click a button that are located in the top of the sheet where the item shall be inserted by using
("E" & (ActiveCell.Row))

i have found one string (see below) that insert the image but how do i get it into the correct cell?
i also need it to be able to filter the sheet and that the images are fixed to the row when sorting by filter.

Thanks in advance
//M

Sub InsertImage()
ActiveSheet.Unprotect "password"
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.ButtonName = "Submit"
.Title = "Select an image file"
.Filters.Clear
.Filters.Add "JPG", "*.JPG"
.Filters.Add "JPEG File Interchange Format", "*.JPEG"
.Filters.Add "Graphics Interchange Format", "*.GIF"
.Filters.Add "Portable Network Graphics", "*.PNG"
.Filters.Add "Tag Image File Format", "*.TIFF"
.Filters.Add "All Pictures", "*.*"

If .Show = -1 Then
Dim img As Object
Set img = ActiveSheet.Pictures.Insert(.SelectedItems(1))

img.Left = 50
img.Top = 150

img.Width = 68
img.Height = 22
Placement = xlMoveAndSize
Else
MsgBox ("Cancelled.")
End If
End With
ActiveSheet.Protect "password", AllowFiltering:=True, AllowFormattingCells:=True, DrawingObjects:=False
End Sub
 
I have a procedure that inserts images and my research has shown that the only way to get the image inserted in a specific cell is to make that cell the activecell when you do the insert. As far as I know Pictures in not a member of the cells class or range class.
 
Last edited:
Upvote 0

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