+ Reply to Thread
Results 1 to 12 of 12

Insert Picture To Cell in Col A with pic name in Col B

  1. #1
    Registered User
    Join Date
    02-24-2011
    Location
    Rockland, NY, USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Insert Picture To Cell in Col A with pic name in Col B

    Searched forum for two days and tried everything related to inserting pictures to get this to work. So, HELP! Please!

    I have to file an insurance claim due to a fire in my home. I have a folder with .jpg photos located at C:\InsClaimOnlinePhotos\ . Im working with Excel 2003. I am trying to put the picture of the damaged protery in Column A on the same row as the detail about that damaged property using the ActiveSheet.Pictures.Insert function. The name of the picture is located in Column B. There are multiple sheets in the Excel book and each contains from 10 to over 700 rows. I would like to run the macro based on the active sheet to add the pictures one sheet at a time. I would like the pictures to be about 1.2" High by 1.6" Wide and be actually be within the cell of Column A of the row where the detail information is located. I have played with writing my own code, pieces of others code and full code sets I found in the Forum. Nothing works. Below is the best I found so far but, it uses Column C for the placement of the pictues.

    When I try to run the below code I get Run-Time Error "1004" "Unable to get the insert Property of the Picture class".

    I'm not sure if this code should work in Excel 2003 or not.

    Thank you in advance for your help.


    Here is the code:
    Please Login or Register  to view this content.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Insert Picture To Cell in Col A with pic name in Col B

    Hello,

    What do you have in column C? it needs to be a number not a cell address. That was the only error I had when I ran the code.
    Last edited by davesexcel; 02-25-2011 at 05:14 AM.

  3. #3
    Registered User
    Join Date
    02-24-2011
    Location
    Rockland, NY, USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Insert Picture To Cell in Col A with pic name in Col B

    Ya, at first I had a cell address (A1) and received an error. When I changed it to a number (1) that error as resolved and debug moved to a new line. the new error is a Run-Time Error "1004" "Unable to get the insert Property of the Picture class". I found some reference online to the error being Microsoft file access flaw but, in playing with various code sets, I was able to pull in some pictures but the overstacked on eachother so, I know that's not the issue.

    I'm thinking that the code runs in 2007 but, something is keeping it from working in 2003.

  4. #4
    Registered User
    Join Date
    02-24-2011
    Location
    Rockland, NY, USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Insert Picture To Cell in Col A with pic name in Col B

    OK ! Hold on a min. I just found an error in the path and fixed it. The picutes are loading into the Excel Sheet until a file is missing. Where a picture file is missing we get the error "1004". Totally logical. But, All the photos are stacking in onto of eachother in the top left corner of the sheet and not going into the the cell in Column A of the active row.

    thanks for making me think harder! Now, I would appreciate help with the below two issues:

    1. Placing an error message in the Macro that will state that a file is missing.

    2. Fixing the macro so that the pictures load into the Cell of Column A for the active row. I have the number "1" in column C. Am I referencing the location to put the picture correctly? or is it a macro code issue?

    In advance, Thank YOU! so much!

  5. #5
    Registered User
    Join Date
    02-24-2011
    Location
    Rockland, NY, USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Insert Picture To Cell in Col A with pic name in Col B

    I figured out that the number value in Column C is the Row position. But, the seem to be laying on top of the cells rather than inside the cells. If I change the hight of the row the Pictures slide up and overlap eachother as one would expect if they were contained in the cell. But, when I reduce the width of column A, the pictures remain in position and the text in Column B slides behind the photo, which indicates that the photo is laying on the cell and not within the cell. Is that just the way it is, or can that be fixted so that size of the cells in Column A dictates how much of the Picture can be viewed?

  6. #6
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Insert Picture To Cell in Col A with pic name in Col B

    Dear EBTI,

    I have a NON_VBA Option which works fantastically, if you want please check the below link and the explantion a nd a file in the other thread:

    http://www.excelforum.com/excel-prog...condition.html

    Just for the readers to make it useful..

    1. Create a list of Picture Names and Pictures Next to it in the adjoining column in a Sheet renamed as Picture Database
    Ex:- Col A - Picture Name & Col B - Pictures.

    2. Remove any Borders and Remove Gridlines in the above sheet..
    Name - >
    Code:

    Picture =OFFSET('Picture DataBase'!$B$2,MATCH(Selection!$A$2,PictureList,0)-1,0,1,1)3. In any other sheet named Selection - create a simple dropdown with the List of all names as shown below:
    Name - >
    Code:
    PictureList = OFFSET('Picture DataBase'!$A$2,0,0,COUNTA('Picture DataBase'!$A:$A),1)4. Select any cell with a Picture in it the Picture Database sheet and then click on the Camera Icon in Excel 2007 and then paste in the Selection sheet in a cell where you owuld like the dynamic pictures to appear and immediately rename it to Picture.. if you have de-clicked it please click again and the formula toolbar just add as =Picture and there you go..

    5. Try selecting any other name and you would get a different picture for every selection..

    Wow..So cool....

    Regards
    E

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Conditional compilation arguments vba

    Use this bit of code to get the list of jpg files in the folder, then that part of the error would be eliminated.
    Please Login or Register  to view this content.
    .JPG will still remain in the file name so that part of your original code would not be required.
    Attached Files Attached Files
    Last edited by davesexcel; 02-26-2011 at 08:32 AM.

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: Insert Picture To Cell in Col A with pic name in Col B

    Dave
    Unfortunately your attachment does not work in 2007 (Application.Filesearch)
    Good for 2003 though

    Regards
    John

  9. #9
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Insert Picture To Cell in Col A with pic name in Col B

    Right then, give this a go.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: Insert Picture To Cell in Col A with pic name in Col B

    That does the trick Dave.
    Are you plowing snow too?

    Thanks and Regards
    John

  11. #11
    Registered User
    Join Date
    10-14-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Insert Picture To Cell in Col A with pic name in Col B

    How would i get this code working for excel 2010

  12. #12
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Insert Picture To Cell in Col A with pic name in Col B

    Quote Originally Posted by acraens View Post
    How would i get this code working for excel 2010
    try this,
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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