+ Reply to Thread
Results 1 to 9 of 9

Insert multiple picture file in excel with vba

  1. #1
    Registered User
    Join Date
    08-06-2012
    Location
    Toronto Canada
    MS-Off Ver
    Excel 2003
    Posts
    8

    Insert multiple picture file in excel with vba

    Hi,

    I want to thanks every one for helping me out and your help is highly appreciated!

    I am creating an excel sheet, where I have to insert hundreds of picture beside the data, how would I do that? I have no experience with VBA or Macros at all and I would like to have code of it please.

    Here is the cache, my picture file is not as same as my product name completely but I would like to have the VBA matches the data with picture by using the 1st 6 Alphanumeric. For instance, my data name is A12345 but the picture name is A12345bkl.jpg.

    I would like to have my picture listed on column B and file name will on column D. Also auto reduce picture to cell size like column 15 X row 73.

    Thank you very much

    Peter

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Insert multiple picture file in excel with vba

    this is an example to be arranged
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-06-2012
    Location
    Toronto Canada
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Insert multiple picture file in excel with vba

    Hi patel45,

    Thank you very much for the code, but the message box show up
    Picture " & xName & " not available.

    Then another message show up in VBA
    Compile error message:
    Sub or Function not defined

    I change the directory path to my picture location but it does not work so I have create D:\Photo\ directory and put all my picture in there and it does not work as well

    It shows the yellow highlight on
    Function InsertPicture(xRange As String, xRigo As Integer, xPatName As String, dRange As String)

    and blue highlight on
    DelBandiera ("image" & xRigo)

    Sorry I'm a VBA dummy does not have any clue of how to modify the code, except change the directory path.

    Please help
    Thank you

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Insert multiple picture file in excel with vba

    attach your file, I'll adapte the macro

  5. #5
    Registered User
    Join Date
    08-06-2012
    Location
    Toronto Canada
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Insert multiple picture file in excel with vba

    I can't reply with attachment file. I'm posting a new one with attachment.

    http://www.excelforum.com/excel-prog...99#post2891599

    Thank you
    Last edited by junkyman98; 08-11-2012 at 10:51 AM.

  6. #6
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Insert multiple picture file in excel with vba

    two changes
    xRigo = 0 ' was 1
    eliminate DelBandiera ("image" & xRigo)

  7. #7
    Registered User
    Join Date
    08-06-2012
    Location
    Toronto Canada
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Insert multiple picture file in excel with vba

    Hi Patel45,
    Thank you very much for the code, but I have couple of questions
    1: Does the picutre file name have to be exactly the same as data name? My file name only matches 1st 5 alphanumeric so some of the file did not appear in the cell.
    2: Can the picture be loaded with auto resize into column size 15 X row size 75?
    Thank you once again.

  8. #8
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Insert multiple picture file in excel with vba

    1: Does the picutre file name have to be exactly the same as data name? - YES, absolutely
    2: Can the picture be loaded with auto resize into column size 15 X row size 75? - change the line
    Selection.ShapeRange.Height = 15 ' was xHeight

  9. #9
    Registered User
    Join Date
    08-06-2012
    Location
    Toronto Canada
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Insert multiple picture file in excel with vba

    Thank you so much patel45
    Please help me with one more question, how do I make a picture auto size to 2.41cm X 2.41cm?
    Thank you very very much

+ 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