Forum Discussion
VBA Excel Macro - Picture attached to Cell (insert) - Not link
I'm not sure if I understood it correctly from the translation, but I'm still sending you this VBA code with a selection function. If this is not what you had in mind, just ignore it.
Option Explicit
Sub InsertPicture()
Dim sPicture As String, pic As Picture
sPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif), *.gif; *.jpg; *.bmp; *.tif", _
, "Select Picture to Import")
If sPicture = "False" Then Exit Sub
Set pic = ActiveSheet.Pictures.Insert(sPicture)
With pic
.ShapeRange.LockAspectRatio = msoFalse
.Height = ActiveCell.Height
.Width = ActiveCell.Width
.Top = ActiveCell.Top
.Left = ActiveCell.Left
.Placement = xlMoveAndSize
End With
Set pic = Nothing
End Sub
I would be happy to know if I could help.
Nikolino
I know I don't know anything (Socrates)
* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.
- Gstg72Dec 03, 2020Copper Contributor
NikolinoDE Thank you again for your response. But this doesn't seem to work.
The pictures are not actually inside the spreadsheet. For example if you email the spreadsheet and attempt to open it on another device or using office online, you will notice the picture are not there.
- NikolinoDEDec 04, 2020Gold Contributor
Its Works for me
Look the file please.
* It is also helpful to know the operating system and Excel version, as different approaches may be required depending on the version and OS.
I would be happy to know if I could help.
Nikolino
I know I don't know anything (Socrates)