Insert Images as Embedded Images

mweick

New Member
Joined
Nov 9, 2012
Messages
22
Hello, I am trying to insert these images in Excel 2010 but everytime I run this Macro they get inserted as linked images. Any advice?

<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;"> Sub AddPictures()
Dim myPic As Picture
Dim wkSheet As Worksheet
Dim myRng As Range
Dim myCell As Range
Dim rowCount As Long
Dim rowCount2 As Long

Set wkSheet = Sheets(2) ' -- Change to your sheet

'-- The usual way of finding used row count for specific column
rowCount2
= wkSheet.Cells(wkSheet.Rows.Count, "C").End(xlUp).Row

If rowCount2 <> 0 Then
Set myRng = wkSheet.Range("C2", wkSheet.Cells(wkSheet.Rows.Count, "C").End(xlUp))

For Each myCell In myRng.Cells
If Trim(myCell.Value) = "" Then
MsgBox
"No file path"
ElseIf Dir(CStr(myCell.Value)) = "" Then
MsgBox myCell
.Value & " Doesn't exist!"
Else
myCell
.Offset(0, 1).Parent.Pictures.Insert (myCell.Value)

With myCell.Offset(0, 1) '1 columns to the right of C ( is D)
'-- resize image here to fit into the size of your cell
myPic
.Top = .Top
myPic
.Left = .Left
myPic
.Placement = xlMoveAndSize
End With
End If
Next myCell

Else
MsgBox
"There is no file paths in your column"
End If
End Sub</code>
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Try it with this line:

myCell.Offset(0,1).Parent.Pictures.Insert (myCell.Value)
 

mweick

New Member
Joined
Nov 9, 2012
Messages
22

ADVERTISEMENT

That's the line I already have in there, are you saying insert your tip above into this line?
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Yes

myCell.Offset(0,1).Parent.Shapes.AddPicture(myCell.Value, False, True, 1, 1, 1, 1)
 

mweick

New Member
Joined
Nov 9, 2012
Messages
22

ADVERTISEMENT

That's what I had in there from your original suggestion and it kicks back this:

Compile error:

Expected: =
 

mweick

New Member
Joined
Nov 9, 2012
Messages
22
Yep I already tried that and receive "Object doesn't support this property or method" when running script
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
I'm not sure what to say, I have this working in one of my projects, which loads an image from a form:

<font face=Calibri>                    <SPAN style="color:#00007F">With</SPAN> lstObj.DataBodyRange.Cells(x, y)<br>                        .Select<br>                        .Value = Me.lbl_Image.Caption<br>                    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>                    wsDest.Shapes.AddPicture FileName:=Me.lbl_Image.Caption, linktofile:=msoFalse, _<br>                        savewithdocument:=msoCTrue, Left:=0, Top:=0, Width:=100, Height:=100</FONT>

Note that I'm selecting the cell where the image should be placed.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,444
Messages
5,642,168
Members
417,258
Latest member
amk1979

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
Top