+ Reply to Thread
Results 1 to 9 of 9

need a vba code to insert pictures with a corresponding file name

  1. #1
    Registered User
    Join Date
    05-18-2015
    Location
    LOS ANGELES
    MS-Off Ver
    2013
    Posts
    9

    need a vba code to insert pictures with a corresponding file name

    Hello

    im pretty new at VBA basically very little to no knowledge but i can get myself around easier codes.

    my problem is that i have a folder with a lot of photos and i need to import them all and have them resized into my sheet. column A would have all my photos. column B has the corresponding filename info.

    the cell height and width are 150, 30

    is there any way i can have the code look for two parts of a filename so that it goes into the right cell?

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: need a vba code to insert pictures with a corresponding file name

    Probably, but you'd need to give us a little more to go on. I can't just assume what those file parts are, how you've formatted the words, or where you'd like them to go. I'm not even really sure what Filename Info means. Is this a directory? You should attach a sample.

    Let's pretend you had a list of filenames in B that were in the same folder as the Excel file and you wanted the pictures to be placed in A, you'd run with something like:

    Please Login or Register  to view this content.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Registered User
    Join Date
    05-18-2015
    Location
    LOS ANGELES
    MS-Off Ver
    2013
    Posts
    9

    Re: need a vba code to insert pictures with a corresponding file name

    Hey Daffodil11

    thanks for that info!

    I am attaching a spreadsheet its very basic. but what i meant with the file parts was that if i can get the Style# and Color columns looked up into the sheet. Or do i have to name the photo just one of those columns because there can be duplicates in different colors etc.

    the photos are not in the same area as the excel file.
    I have a separate folder on the desktop where all the pictures should be pulled from.
    I also need thees to be emailed and show the pictures when someone else opens this file.

    let me know if you need anymore info!
    Attached Files Attached Files

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: need a vba code to insert pictures with a corresponding file name

    Is STYLE supposed to be a filename?

    As for dynamically pulling Exif-type from photos, you'd likely need to invoke some sort of program with Shell to force it to run, and then manipulate that program to figure out each photo's properties. That would be pretty tricky stuff. Something super involved and complex like that might be better fielded by Commercial Services.

    Why would you need to reload the images when the file opens? Do you have a need to continually re-import the pictures?

    Email is pretty easy and can be tailored around a lot of different actions. What do you want to email? To whom, and how?

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-18-2015
    Location
    LOS ANGELES
    MS-Off Ver
    2013
    Posts
    9

    Re: need a vba code to insert pictures with a corresponding file name

    STYLE would be the filename in the photos.

    i read somewhere that the macros would have to be continually activated each time you opened the file?
    unless i read that part wrong

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: need a vba code to insert pictures with a corresponding file name

    Depends on the type of procedure. Some macros run once, do what you need, and then you don't need them anymore.

    For example, if I want to know everytime someone opens one of my files, I might have an Event procedure that writes the date, time, and username of anyone who opens one of my workbooks to an Access database. I'd use Workbook_Open or _BeforeSave

    In another example, I might want to send an email to every email address in Column D, with subject E, copying F, with a Body composed of G, H, & I. I'd do this one time only, to save myself a couple days of work, and then probably never again. This would just be a standard routine.

  7. #7
    Registered User
    Join Date
    05-18-2015
    Location
    LOS ANGELES
    MS-Off Ver
    2013
    Posts
    9

    Re: need a vba code to insert pictures with a corresponding file name

    So what would be the full code to have the photos pull from a folder on my desktop. where do i put the file path name? in the first code you showed me?

  8. #8
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: need a vba code to insert pictures with a corresponding file name

    We just remove the variable filepath string and put in a hardcoded one. This would pull in file names from Column B that exist in the filepath you list

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-18-2015
    Location
    LOS ANGELES
    MS-Off Ver
    2013
    Posts
    9

    Re: need a vba code to insert pictures with a corresponding file name

    so just tried this on my sheet and it keeps saying a error 400
    i am using excel 2013

    also did find a old code but can't seem to get this one to work either

    Please Login or Register  to view this content.
    this one just places the pictures in the cell right next to it.
    I need it to pull data from Column B and the populate the pictures in Column A
    attached a updated spreadsheet
    Attached Files Attached Files

+ 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. Error in code to insert pictures in excelsheet
    By Danielle22 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-30-2013, 01:24 PM
  2. VBA or Macro code to insert pictures in cell
    By thedefense in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2013, 03:47 PM
  3. Insert/Delete Multiple Pictures but 1 or more pictures not available
    By MrNoodles in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2012, 02:10 PM
  4. insert pictures code, needs editing
    By ufopilot3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-31-2012, 09:48 AM
  5. Replies: 7
    Last Post: 11-14-2005, 10:40 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