+ Reply to Thread
Results 1 to 7 of 7

Insert images in cells

Hybrid View

Lorenzo_73 Insert images in cells 06-21-2009, 07:01 PM
Leith Ross Re: Insert images in cells 06-22-2009, 02:17 AM
Lorenzo_73 Re: Insert images in cells 06-22-2009, 02:23 AM
Leith Ross Re: Insert images in cells 06-22-2009, 02:37 AM
royUK Re: Insert images in cells 06-22-2009, 02:37 AM
Lorenzo_73 Re: Insert images in cells 06-22-2009, 08:30 PM
Leith Ross Re: Insert images in cells 06-22-2009, 09:04 PM
  1. #1
    Registered User
    Join Date
    06-21-2009
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    3

    Insert images in cells

    First off all, sorry for my bad english,
    I hope anyway, that you would be able to understand me )

    Simplifying, this is what I would like to do:

    I have three columns:
    in the cells of column A, there is text
    in the cells of column B, there is text
    in the cells of column C, I would like to insert, using macro, different images.


    The images in each cell of column C should be taken in:
    "C: \ path \ images" + "the text of the cell in the A column of the same line" +. "Jpg"

    That is:
    C1: "C: \ path \ images" + A1 +. "Jpg"
    C4: "C: \ path \ images" + A4 +. "Jpg"
    C7: "C: \ path \ images" + A7 +. "Jpg"
    C10: "C: \ path \ images" + A10 +. "Jpg"

    And so on every three lines...

    This is why: each cell where I want to insert the image if followed by 2 other lines with extra data.


    That is, as stated before,
    I would like the macro will work only in the cells:
    C1, C4, C7, C10, C13, C16, C19, C22, etc. (every 3 line in the cell in "C" column)

    Can you help?

    A person in another forum to insert images in cells posted this macro,
    but I don't know how to change it to resolve my problem

    Public Sub m()
    
    Dim sImmagine As String
    Dim sPath As String
    Dim c As Range
    Dim rng As Range
    Dim sh As Worksheet
    Dim lLarghezza As Long
    
    sPath = "C:\Prova\"
    Set sh = Worksheets("Foglio1")
    
    With sh
    Set rng = .Range("H1:H20")
    For Each c In rng
    If c.Value <> "" Then
    sImmagine = ""
    sImmagine = sPath & _
    c.Value & ".jpg"
    If Dir(sImmagine) <> "" Then
    c.Select
    .Pictures.Insert( _
    sImmagine).Select
    Selection.ShapeRange.Width = _
    c.Width
    End If
    End If
    Next
    
    End With
    
    Set c = Nothing
    Set rng = Nothing
    Set sh = Nothing
    
    End Sub
    



    Thank you really a lot!!!
    Last edited by Leith Ross; 06-22-2009 at 02:16 AM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Insert images in cells

    Hello Lorenzo-73,

    Welocme to the Forum!

    To make your posts easier to read, copy, and edit please wrap your code. I did it for you this time. Here is how you can do it next time.

    How to wrap your Code
    1. Select all your code using the mouse.
    2. Click on the # icon on the toolbar in the Message window. This will automatically wrap the text you selected with the proper Code tags to create a Code Window in your post.

    3. You can also do this manually by placing the tags
    [code] at the start of the line,
    [/code] at the end of the line.


    As a member, You have agreed to follow the forum posting rules. Please take so time to familiarize yourself with the Do's and Don'ts here in the Forum, just click on the link below...

    Forum Rules
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    06-21-2009
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Insert images in cells

    Quote Originally Posted by Leith Ross View Post
    Hello Lorenzo-73,

    Welocme to the Forum!

    To make your posts easier to read, copy, and edit please wrap your code. I did it for you this time. Here is how you can do it next time.
    Ok, thank you for the explanation,
    and sorry

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Insert images in cells

    Hello Lorenzo_73,

    Non si preoccupi.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Insert images in cells

    Which version of Excel are you using?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    06-21-2009
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Insert images in cells

    Quote Originally Posted by royUK View Post
    Which version of Excel are you using?
    Hi Roy,
    I'm using the 2003...

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Insert images in cells

    Hello Lorenzo_73,

    Will the picture's height be equal to 3 cells?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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