• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Import pic with Reference

Dear All,

I have Attached the excel sheet and 4 images.
in excel sheet Name and The four Image names. I want to import those pic with any automatic method. I have to work with more images. please help
 

Attachments

  • Images.zip
    14.9 KB · Views: 3
Your file size is only 21.3 KB yet you are forcing viewers to unzip a file, most will treat a zip with suspicion.

Why not hyperlink.


.
 
Your file size is only 21.3 KB yet you are forcing viewers to unzip a file, most will treat a zip with suspicion.

Why not hyperlink.


.
Hi Bobhc,
I cant upload more than 3 files so i zipped.. If i do hyperlink i cant do for 300+ pic. Even i do it. I want it to visible in the cell or parallel to the file name. Please Find the Excel sheet now i attached. Like this i want. I have more than 300 pic like this.
 

Attachments

  • Image import.xlsx
    23.6 KB · Views: 4
Found this code on web, but have changed a bit for your need.

Copy this UDF code to your workbook module and use as a function on your Excel cell. By default the image fits to your cell otherwise you can specify a range as well where you want to expand your image.

Code:
Public Function InsertPictureInRange(PictureFileName As String, Optional TargetRange As Range)
' inserts a picture and resizes it to fit the TargetCells range
Dim p As Object, t As Double, l As Double, w As Double, h As Double
  If TypeName(ActiveSheet) <> "Worksheet" Then Exit Function
  If Dir(PictureFileName) = "" Then Exit Function
 
  ' import picture
  Set p = ActiveSheet.Pictures.Insert(PictureFileName)
  ' determine positions
If TargetRange Is Nothing Then
  With ActiveCell
  t = .Top
  l = .Left
  w = .Width
  h = .Height
  ' w = .Offset(0, .Columns.Count).Left - .Left
  'h = .Offset(.Rows.Count, 0).Top - .Top
  End With
Else
  With TargetRange
  t = .Top
  l = .Left
  w = .Width
  h = .Height
  ' w = .Offset(0, .Columns.Count).Left - .Left
  'h = .Offset(.Rows.Count, 0).Top - .Top
  End With
End If
  ' position picture
  With p
  .Top = t
  .Left = l
  .Width = w
  .Height = h
  End With
  Set p = Nothing
End Function

Once the code is on the module, use the function InsertPictureInRange() and pass the image path as the parameter. This should import the picture onto the cell.

Eg :
InsertPictureInRange(B6)
where B6 holds the path of your image. This should bring the image on cell B6.

=InsertPictureInRange(B6,D6:H10)
where B6 holds the path of your image. This should bring the image on Range D6:H10.

Let me know, if this works for you.

Cheers.
 
Found this code on web, but have changed a bit for your need.

Copy this UDF code to your workbook module and use as a function on your Excel cell. By default the image fits to your cell otherwise you can specify a range as well where you want to expand your image.

Code:
Public Function InsertPictureInRange(PictureFileName As String, Optional TargetRange As Range)
' inserts a picture and resizes it to fit the TargetCells range
Dim p As Object, t As Double, l As Double, w As Double, h As Double
  If TypeName(ActiveSheet) <> "Worksheet" Then Exit Function
  If Dir(PictureFileName) = "" Then Exit Function

  ' import picture
  Set p = ActiveSheet.Pictures.Insert(PictureFileName)
  ' determine positions
If TargetRange Is Nothing Then
  With ActiveCell
  t = .Top
  l = .Left
  w = .Width
  h = .Height
  ' w = .Offset(0, .Columns.Count).Left - .Left
  'h = .Offset(.Rows.Count, 0).Top - .Top
  End With
Else
  With TargetRange
  t = .Top
  l = .Left
  w = .Width
  h = .Height
  ' w = .Offset(0, .Columns.Count).Left - .Left
  'h = .Offset(.Rows.Count, 0).Top - .Top
  End With
End If
  ' position picture
  With p
  .Top = t
  .Left = l
  .Width = w
  .Height = h
  End With
  Set p = Nothing
End Function

Once the code is on the module, use the function InsertPictureInRange() and pass the image path as the parameter. This should import the picture onto the cell.

Eg :
InsertPictureInRange(B6)
where B6 holds the path of your image. This should bring the image on cell B6.

=InsertPictureInRange(B6,D6:H10)
where B6 holds the path of your image. This should bring the image on Range D6:H10.

Let me know, if this works for you.

Cheers.
Hi Lohith,
You rocking.Awesome... Thanks a lot i don't know what to say more than this.
:);):cool::awesome:
 
Back
Top