+ Reply to Thread
Results 1 to 8 of 8

Mass print images

  1. #1
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Mass print images

    I have a repetitive job where I need to print a series if images in a folder (probably will be jpg but I think I'd just ensure the folder only had the things I wanted printing in it) and I want to cycle through all of them and print them all to fit the page.
    can I have some code to easily do this?
    Last edited by scottiex; 03-18-2019 at 08:52 PM.
    If you want something done right... find a forum and ask an online expert.

    Time flies like an arrow. Fruit flies like a banana.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,958

    Re: Mass print images

    I just went through working with picture files in a directory for my own purposes, so I probably have pieces of the code you need.

    Some questions about "to fit the page:" What do you mean by this? Obviously you want to scale down any image that is too big. Do you want stretch smaller images to fit? Do you want the best aspect ratio? Do you want to switch between landscape and portrait to get the best fit?

    What size paper do you want to use and what is its dimensions?

    Also, I am not sure if the regional settings will give us an issue. I'm dealing with inches, and you are most likely dealing with cm. There are 72 points to an inch. Does that mean there are 29.4 points to a centimeter? How do I get .4 points? Or do the regional settings take this into account?
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: Mass print images

    Quote Originally Posted by dflak View Post
    Some questions about "to fit the page:" What do you mean by this? Obviously you want to scale down any image that is too big. Do you want stretch smaller images to fit?
    Yes - just resize to match the width of the page would be fine.
    Maybe make sure it isn't too tall but I cant see that being likely to happen.

    Keep the height width ratio - I don't want to stretch images and I don't think we need to switch between landscape and portrait - however if it did do that that would also be fine.

    We would print on what we call A4 paper
    A4 measures 210 × 297 millimeters or 8.27 × 11.69 inches.

    Or do the regional settings take this into account?
    well I hope it will just work out - but I can't see this being a big issue - I am competent enough to amend code if needed

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,958

    Re: Mass print images

    I'll work it out for letter sized and give you definable constants to fit your needs.

    Now I have to find some suitable pictures .

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

    Re: Mass print images

    "Keep the height width ratio" and "fit the page" might not be possible.

    I have the attached stored for special occasions. Is this something you can adjust to what you need?
    Attached Files Attached Files

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,958

    Re: Mass print images

    I wrapped myself around the axle most of the morning trying to get the scaling part of the application to work out. I wanted to make sure that pictures that were larger than the sheet didn't wrap over to another sheet.

    Then I took my own advice. Let Excel do the "heavy lifting" and use the VBA to do only those things VBA can do. The approach I came up with doesn't depend on regional settings.

    On the Control Panel in Cell B1, enter the path name to the directory containing the pictures. The rest of the cells on this sheet are used to generate the output report name which will come out in the same directory with the application.

    The report works by adding sheets to a new workbook.

    The program loops through the directory getting all JPEG files and it gets the width and height of each picture. It computes the ratio of width to height, and if it is wider than it is high, it's landscape, otherwise it's portrait. The program decides which template to copy into the new workbook and then puts the picture on that sheet.

    The magic occurs in the two template sheets. I have one for Portrait and One for Landscape. These sheets can be configured with any size margins, headers / footers and whatever you want. I chose to center the pictures. However, make sure that the scaling is "Fit on one Sheet." What I fought with all morning, Excel does automatically. You should configure these sheets to meet your requirements (paper size and margins, etc.)

    The sheets in the new workbook have the same name as the file name.

    You might notice that GetImageDimensions uses Imperial measurements. Not to worry. The only thing I use these measurements for is to compute the ratio. The Fit All on One Sheet will work in any regional setting and for any size paper.

    I only wrote the Main Subroutine, the Constants and the GetImageDimensions and the GetPic are borrowed code.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: Mass print images

    thank you both,
    Now I will just do a little testing to see which is best for my purpose, but both are a huge step forward.

  8. #8
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: Mass print images

    Thanks we will be using dflak's version.
    Both of your input is much appreciated.

+ 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. Print for images in the pages
    By ninhmoon in forum Excel General
    Replies: 0
    Last Post: 09-23-2015, 11:24 PM
  2. Mass hyperlinking images?
    By j4k3y in forum Excel General
    Replies: 1
    Last Post: 07-01-2013, 06:56 AM
  3. macro to print without images
    By dejvione in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2012, 04:52 AM
  4. [SOLVED] How do you print images in excel 2007
    By ddd444 in forum Excel General
    Replies: 0
    Last Post: 07-28-2006, 07:50 PM
  5. [SOLVED] print images in excel 2007
    By ddd444 in forum Excel General
    Replies: 0
    Last Post: 07-14-2006, 05:05 PM
  6. Re: Images are resizing in print
    By The Analyser in forum Excel General
    Replies: 0
    Last Post: 07-04-2006, 11:30 AM
  7. How do you print images from excel?
    By plz help in forum Excel General
    Replies: 1
    Last Post: 11-01-2005, 10:05 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