+ Reply to Thread
Results 1 to 4 of 4

New to VBA - creating code to paste photos from file to corresponding part # in Excel?

  1. #1
    Registered User
    Join Date
    03-01-2016
    Location
    Phoenix, AZ
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Question New to VBA - creating code to paste photos from file to corresponding part # in Excel?

    Hey guys,

    I am new to VBA - trying to learn. I did a little bit of MATLAB in school, but I am mostly a complete beginner to all of this.

    I have a folder with about 30,000 photos in it. These photos are labeled 00001 - 30,000. I have a spreadsheet that has corresponding part numbers (formatted as 00001 through 30000) along with tons of other data corresponding to the part number.

    I would like to be able to simply import the photo from the folder into the Excel sheet to match with the corresponding part numbers. I suppose you would want the code to resize whatever cells you were placing the photo in as well.

    I am not sure if this is something you guys can help with this limited amount of info, but anything is appreciated. I have a coworker who actually wrote this code already - but I am having a tough time keeping track of what is going on and I am wondering if I can write the code myself without getting lost.

    Thanks!

  2. #2
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: New to VBA - creating code to paste photos from file to corresponding part # in Excel?

    Hi,

    Something like this should work.

    Please Login or Register  to view this content.
    You will need to make some changes to the code.
    - Change the file location
    - Possible change the file type (I have assumed that they are all .jpg)
    - I have assumed that the labels are in column A and that the pictures are in column B (Note I only used 5 pictures in my testing i.e. Range("B2:B6") with labels in A2:A6)
    - Also note, I have resized the pictures to fit into the cell rather than fitting the cell around the pictures.

  3. #3
    Registered User
    Join Date
    03-01-2016
    Location
    Phoenix, AZ
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Re: New to VBA - creating code to paste photos from file to corresponding part # in Excel?

    Thanks a lot I will play around with that a bit and see how it goes. These pictures are actually .tif files. So what is this code doing:
    .Top = rng.Top
    .Left = rng.Left
    .Height = rng.Height
    .Width = rng.Width

    I understand some of this code such as defining your variables "range" and "file" in the beginning...but I get lost in some of the other parts of the code. I really ought to take some classes in VBA code - looks like a lot of fun once you know what your doing.

  4. #4
    Valued Forum Contributor spitfireblue's Avatar
    Join Date
    01-29-2015
    Location
    Adelaide, Australia
    MS-Off Ver
    2007,2010,2016
    Posts
    611

    Re: New to VBA - creating code to paste photos from file to corresponding part # in Excel?

    Hi,

    The below code is resizing the picture to the dimension of the cell.

    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)

Similar Threads

  1. How to hyperlink photos in Excel File
    By jacksonmathews in forum Excel General
    Replies: 7
    Last Post: 02-08-2017, 12:45 AM
  2. Replies: 0
    Last Post: 10-29-2013, 09:38 AM
  3. Vlookup to Insert photos compiled in a Folder to en Excel file
    By aleifer12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2012, 12:27 PM
  4. Vlookup to Insert photos compiled in a Folder to en Excel file
    By aleifer12 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2012, 11:59 AM
  5. Parse Part of File name and paste into excel
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-15-2010, 06:12 PM
  6. Creating File Path to Photos
    By clawrence04 in forum Excel General
    Replies: 0
    Last Post: 03-26-2009, 03:00 PM
  7. Replies: 2
    Last Post: 07-28-2006, 10:20 AM

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