+ Reply to Thread
Results 1 to 9 of 9

Insert picture from folder in excel cell

  1. #1
    Registered User
    Join Date
    12-19-2010
    Location
    Serbia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Insert picture from folder in excel cell

    I want to insert an image from a specific folder in the excel cell by the name.
    Explanation:
    In cell A1 I have name of picture I want to insert e.g. 1234
    In C:\Users\Me\Desktop I have picture with name 1234

    When in A1 I wrote 1234 I want to insert picture from specific folder in cell B1
    I should be able to work with different data of cell A1 (range A1:A1000)

    Can someone help me.
    Last edited by ArH; 01-07-2016 at 03:25 PM.

  2. #2
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Insert picture from folder in excel cell

    To actually insert a picture in B1 from a file location, I think, will require VBA to insert the object.

    To just open the file for viewing something like this in B1 will take the file name from A1 and open it
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Insert picture from folder in excel cell

    The below code
    • loops through each cell in the selected range
    • reads the filename from that cell
    Note: if the file name does not include the file extension you'll need to append it within the code

    • inserts the referenced picture in the cell, at the location you set as FilePath, to the right of the cell:
    • resizes the height and width of the picture to the cell's height

    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Registered User
    Join Date
    12-19-2010
    Location
    Serbia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Insert picture from folder in excel cell

    Thanks Ron it work

    I have problem to put picture with center align
    And I don't know how to append code because I whant that cell A1 have only file name without exstension

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Insert picture from folder in excel cell

    See the edit I made, below. Change the ".jpg" extension to whatever you need.

    Please Login or Register  to view this content.
    I hope that helps.

  6. #6
    Registered User
    Join Date
    12-19-2010
    Location
    Serbia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Insert picture from folder in excel cell

    Thanks work perfect
    Can I automate whole proces
    e.g. if cell range(a1,a10) have value run InsertPicFromFile() for cell with value

  7. #7
    Registered User
    Join Date
    12-19-2010
    Location
    Serbia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Insert picture from folder in excel cell

    Here is whole CODE

    Sub InsertPicFromFile(ByVal Target As Range)
    Dim cCell As Range
    Dim FilePath As String

    FilePath = "your directory address"


    For Each cCell In Target
    If cCell.Value <> "" Then
    On Error Resume Next
    ActiveSheet.Shapes.AddPicture _
    Filename:=FilePath & cCell.Value & ".jpg", LinkToFile:=msoFalse, _
    SaveWithDocument:=msoTrue, _
    Left:=cCell.Offset(ColumnOffset:=2).Left, Top:=cCell.Top, _
    Width:=79.65, Height:=106.2
    End If
    Next cCell
    End Sub

    Private Sub Worksheet_Change(ByVal Target As Range)

    On Error Resume Next
    If Target.Value <> Empty Then
    Application.EnableEvents = False
    Call InsertPicFromFile(Target)
    Application.EnableEvents = True
    End If

    End Sub

  8. #8
    Registered User
    Join Date
    02-12-2020
    Location
    Hungay
    MS-Off Ver
    Office 2013
    Posts
    14

    Re: Insert picture from folder in excel cell

    Hi Guys,

    it is an old threat, but lets hope someone can help me.

    MY excel doesnt execute the macro, and if it does I get an runtime Error 424.

    Could somebody help me?

    Im using Office 2013

    Thank You!

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,586

    Re: Insert picture from folder in excel cell

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Insert Picture in cell, click commanbutton to rename picture, lock cell and remove button
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-28-2014, 10:05 PM
  2. [SOLVED] Insert Picture to excel from subfolders and save as folder name
    By gincemathew in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-14-2013, 10:01 AM
  3. VBA for Picture insert at particular worksheet range. Picture name derived from cell.
    By Douglas2013 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2013, 01:16 AM
  4. How can i insert the picture using emp no in excel cell value
    By noorsadhik in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2013, 08:00 AM
  5. Insert newest Picture in folder into Spreadsheet
    By 123rich456 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2012, 02:39 PM
  6. Can we Insert a picture in Excel Cell
    By ualtaf in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-16-2010, 09:41 AM
  7. Insert/format Picture From Folder
    By Vlad999 in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 01-18-2007, 10:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1