Inserting Image

royhern

Board Regular
Joined
Feb 21, 2002
Messages
158
Just wondering is there a way to insert a picture in select group cells and automatic
having the picture to auto adjust width and height within the group of cells.

Thanks, Roy
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
Directly No, but if you use a UserForm then yes.

If you use the photo as a shape then you will not need to use the UserForm.

This code will build a photo library on a sheet, using the photo shape. JSW

Sub s_Photos()
'Adds a photo below the last photo if any.

Application.ScreenUpdating = False
Range("D65536").End(xlUp).Offset(4, -2).Select
ActiveCell.RowHeight = 118.5
ActiveCell.ColumnWidth = 32.43

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
myFile = Application.InputBox("Enter your, ""Drive:PathFile.jpg"" for your Photo." _
& Chr(13) & Chr(13) & " Like, C:MyFilesJSWExcelFOREST03.JPG" & Chr(13) & Chr(13) _
& " In the box below!", Title:="Please indicate the photo location!" _
, Default:="C:MyFilesJSWExcelFOREST03.JPG")
On Error GoTo Kil
'ActiveSheet.Pictures.Insert("C:MyFilesJSWExcelFOREST03.JPG").Select
ActiveSheet.Pictures.Insert(myFile).Select
Selection.ShapeRange.ScaleHeight 0.34, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 0.33, msoFalse, msoScaleFromTopLeft
With Selection
.Placement = xlMoveAndSize
.PrintObject = True
End With
ActiveCell.Offset(0, 2).Select
Selection.Interior.ColorIndex = xlNone
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.MergeCells = False
End With
ActiveCell.FormulaR1C1 = "Photo: "
With ActiveCell.Characters(Start:=1, Length:=8).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("A1").Select
Application.ScreenUpdating = True
Kil:
Range("A1").Select
Application.ScreenUpdating = True

End Sub
 

Forum statistics

Threads
1,144,148
Messages
5,722,786
Members
422,458
Latest member
Muirzy

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