+ Reply to Thread
Results 1 to 12 of 12

[ask] vba code to pull images from folder to each column on excel

  1. #1
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    [ask] vba code to pull images from folder to each column on excel

    Hello,

    I Search on the forum and found vba code which similar to my need. I try to edit them.

    Basically, i want to insert pictures from folder to each column ( B2, C2, D2... an so on, until the last picture).

    the code below, is working, but instead to insert to each column, it just insert to each row ( B2, B3, B4 etc).

    can anyone help?
    also i want all picture have 1 inch size ( height and weight ).

    thanks.


    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 12-11-2014 at 06:12 AM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  2. #2
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: [ask] vba code to pull images from folder to each column on excel

    Try this then
    Please Login or Register  to view this content.
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  3. #3
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: [ask] vba code to pull images from folder to each column on excel

    Thanks it works!

    another question:
    1. how to set all pictures size have 1 inch by weight and height?
    2. all the columns have 175 pixel width, when the pictures copied to the cells, at some point some pictures not are not in center of the cell due to distance of each pictures. is it possible every picture stick to the cells ( picture 1 inside B2, picture inside C2, inside D2....)

    thanks

    update:
    anyway i solved my problem manually by:
    1. format all pictures size to 1 inch ( with locked aspect ratio checked)
    2. format all picture to ( don't move or size with cell)
    3. adjust the column width, and locate all pictures to the place. now it all center to every cells.

    Many thanks for Vikas, you saved my day!
    Last edited by qiyusi; 12-11-2014 at 05:45 AM.

  4. #4
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: [ask] vba code to pull images from folder to each column on excel

    Thanks for the response..

  5. #5
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: [ask] vba code to pull images from folder to each column on excel

    I found that the pictures is not stored as embed pictures in the file. the excel file only 200kb something.
    it should be 4-5 mb.

    so when i send the file to another computer, the pictures can't be displayed.

    anyone can help me how to change existing picture format from link to file picture to embedded picture.
    so it wont break when opening or sending to any computer.
    Last edited by qiyusi; 12-16-2014 at 01:09 AM.

  6. #6
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: [ask] vba code to pull images from folder to each column on excel

    I try to add this code:

    ActiveSheet.Shapes.AddPicture sDir & sPic, False, True, 1, 1, 100, 100

    but it's keep getting error.

  7. #7
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: [ask] vba code to pull images from folder to each column on excel

    I guess revised code for that would be:-

    Please Login or Register  to view this content.
    Last edited by Vikas_Gautam; 12-16-2014 at 04:53 AM.

  8. #8
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: [ask] vba code to pull images from folder to each column on excel

    error.JPG

    not working, syntax error

  9. #9
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: [ask] vba code to pull images from folder to each column on excel

    So try this then
    Please Login or Register  to view this content.
    Edit:- Done some changes
    Last edited by Vikas_Gautam; 12-16-2014 at 05:28 AM.

  10. #10
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: [ask] vba code to pull images from folder to each column on excel

    still not work, i am googling,

    found this code:
    Sub TestInsertPicture()
    InsertPicture "C:\FolderName\PictureFileName.gif", _
    Range("D10"), True, True
    End Sub

    Sub InsertPicture(PictureFileName As String, TargetCell As Range, _
    CenterH As Boolean, CenterV As Boolean)

    so i think maybe the link:=false can add to above code? but i dont know how.

    Sub qiyusipicture ()
    InsertAllPix Range("B2"),"D:\New folder","*.jpg", false
    End Sub

    Sub InsertAllPix(r As Range, ByVal sDir As String, sFilt As String, linktofile as ?????)

  11. #11
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: [ask] vba code to pull images from folder to each column on excel

    Try the above code
    Its working for me.

  12. #12
    Forum Contributor
    Join Date
    10-22-2014
    Location
    Indonesia
    MS-Off Ver
    2010
    Posts
    177

    Re: [ask] vba code to pull images from folder to each column on excel

    Aha!

    yes, finally! don't how know to thank you.
    i struggling to fix the code all day long, and you make it right in a minutes.

+ 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. Replies: 4
    Last Post: 12-11-2013, 04:13 AM
  2. Replies: 9
    Last Post: 10-08-2013, 02:46 PM
  3. Replies: 2
    Last Post: 10-24-2012, 01:39 PM
  4. Copy images from a folder & paste them in Excel
    By karan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-22-2011, 02:40 PM
  5. Replies: 1
    Last Post: 06-23-2005, 07:05 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