+ Reply to Thread
Results 1 to 16 of 16

Creating JPG Files from a List in Excel

  1. #1
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    2007
    Posts
    123

    Creating JPG Files from a List in Excel

    Hello,

    Is there a way for excel/VBA to take a list from excel and turn them into graphics like .jpg or .png files? I have a lot of "Heading" images to make and think this could be an easy way to do it if possible

    For example, in Column A, I would have the filename and Column B I have the Text that I would like to create as an Image. The macro would work down the list until each row had it's own image file in a specified folder. I need the Header to be 400pixels wide by 100pixels high and be able to customize the background color and font color.

    Hope this isn't too crazy of an ask!

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Creating JPG Files from a List in Excel

    How would Excel/VBA know what image to create from the information you are providing ?


    Cols.jpg


    How does VBA know to interpret the information in Col B into the item described there ?
    Last edited by Logit; 02-05-2024 at 06:34 PM.

  3. #3
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    2007
    Posts
    123

    Re: Creating JPG Files from a List in Excel

    My thought is that I could format the cell exactly how I'd like it. For example, I can kind of do what I want to be done by coloring the cells in Column B, formatting the text, making the column width "47.5" and the row height "15". Then if I go to Home, Click the "Copy as Picture" button, Paste, then right click and do save as Picture, it does what I'd like. However, recording a macro to do this does not work.

    .
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: Creating JPG Files from a List in Excel

    I don't know if the images in the sheet are enough for you?
    Please Login or Register  to view this content.
    Artik

  5. #5
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Creating JPG Files from a List in Excel

    Here is a project from my tool box. You'll need to input the image file name in Col D so the macro will know which image to paste from your folder containing the images.

    Please Login or Register  to view this content.
    You'll need to edit the path to suit and make adjustments for the image size.
    Attached Files Attached Files

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

    Re: Creating JPG Files from a List in Excel

    Don't know your request about pixels.
    The changing of colors need to be incorporated.
    Please Login or Register  to view this content.
    Experience trumps academics every day of the week and twice on Sunday.

  7. #7
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    2007
    Posts
    123

    Re: Creating JPG Files from a List in Excel

    Reply to #5. Thank you. This could be handy for another application for me, but I don't think this is quite what I want. I'm looking to generate an image based off the cell data, not insert an image into excel if that makes sense. I think @jolivanes is on the right track with what I need but the code is just spitting out a blank cell image and not utilizing the text or formatting of the cell for whatever reason.
    Last edited by rjj920; 02-06-2024 at 02:13 PM.

  8. #8
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    2007
    Posts
    123

    Re: Creating JPG Files from a List in Excel

    Reply to #4. This is very close. Now if there is just a way to save the images that get created to a named directory (ex: c:/images/)
    Last edited by rjj920; 02-06-2024 at 02:14 PM.

  9. #9
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    2007
    Posts
    123

    Re: Creating JPG Files from a List in Excel

    Reply to #6. Thanks for your help. I think you're on the right track of what I want to do, but this code just outputs a blank cell named ".jpg" and not showing any of the text that is within the cell. I'm not sure why its not working as it seems like your spath line should use the value in Column A, but it's not for me.
    Last edited by rjj920; 02-06-2024 at 02:16 PM.

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

    Re: Creating JPG Files from a List in Excel

    In Posts 8 and 9, put the Post # in that you are referring to.
    What it does for me is make a picture of each cell to the right of the cell in Column A that has data and name it as the cell Value in Column A with that data.

  11. #11
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    2007
    Posts
    123

    Re: Creating JPG Files from a List in Excel

    #10. Your macro did work after all. Thank you! For whatever reason, my version of excel did not like "ThisWorkbook.ActiveSheet" and I had to change to Set sht = ActiveWorkbook.Worksheets("Sheet1").

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

    Re: Creating JPG Files from a List in Excel

    That is better because that way you can run it from any sheet. That was probably your problem.
    If you get blank pictures, I would download Irfanview (it is free) and install it with all the bells and whistles and save your pictures through it.
    I recently changed all my picture and range saving to use Irfanview. It eliminates all the problems associated with using chart objects.
    If you do go that way and you need code, let me know. Two Excel experts (snb and HansV) figured that out for me a while back

  13. #13
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    2007
    Posts
    123

    Re: Creating JPG Files from a List in Excel

    I'll have to check out lrfanview. Do you mind sharing the code while I've got you? Could be a good weekend project for me.

    I noticed that when my images get saved it creates a white border around it. Maybe this is one of the issues you've noticed with Chart Objects? If not, is there any code that could eliminate that?

    Attachment 858660

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

    Re: Creating JPG Files from a List in Excel

    Have a read here.
    https://eileenslounge.com/viewtopic....312675#p312675

    Please Login or Register  to view this content.
    Your attachment does not work. Read the yellow banner at the top.

  15. #15
    Forum Contributor
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    2007
    Posts
    123

    Re: Creating JPG Files from a List in Excel

    Here is what I came up with thanks to your help. You may have to step though some of the code since our directories won't match. The issue I am having trouble with now is just the outline around the graphic. When it gets saved to the folder, it has a white border around the image. However, if I manually "copy as picture" and paste as picture within the workbook, there is no border.
    Attached Images Attached Images
    Attached Files Attached Files

  16. #16
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: Creating JPG Files from a List in Excel

    Try the emf format, which more faithfully reproduces the cell image. The code is a bit long.
    In one standard module code from Stephen Bullen:
    Please Login or Register  to view this content.
    In the second standard module:
    Please Login or Register  to view this content.
    Artik

+ 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. Creating multiple excel files based on list of items
    By AlexeyY in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-15-2016, 06:22 PM
  2. macro for creating large list of files based form one template file
    By stindzis in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-26-2014, 03:02 PM
  3. Creating Files with a Drop Down List
    By raphiduani in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-11-2013, 03:09 AM
  4. Replies: 1
    Last Post: 01-31-2012, 09:07 PM
  5. Creating a list of files with file sizes
    By CobraLAD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2011, 02:21 AM
  6. Creating a list, from data in a bunch of different files
    By Sibrulotte in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-25-2009, 05:22 PM
  7. Creating an Excel list of Excel Files
    By kasimagj in forum Excel General
    Replies: 5
    Last Post: 01-13-2009, 01:58 PM

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