+ Reply to Thread
Results 1 to 6 of 6

Use VBA to add file names, file sizes and images (if jpg or png) to cells and re-size

  1. #1
    Registered User
    Join Date
    06-20-2015
    Location
    US
    MS-Off Ver
    2013
    Posts
    11

    Use VBA to add file names, file sizes and images (if jpg or png) to cells and re-size

    I have a folder with a set of files (pdf, png, jpg and ppt).

    What I would like to do is use VBA to do the following:
    - user browses to select target folder
    - selects a button
    - for each pdf, png, jpg and ppt file in the folder
    - in column A displays file name (e.g. picture1.jpg or bestplaces.pdf)
    - in column B displays file type (e.g. jpg, pdf)
    - in column C displays image if file type = jpg or png
    - and the cell that contains an image automatically resizes to fit the width/height of the image (would be great if it could set a specific cell height and resizes the image to fit accordingly and the width is variable dependent on the aspect ratio of the image)
    - in column D displays the file size

    I have found snippets of code from different threads that accomplish a small portion of this goal but I can't seem to combine them in a way that makes it all work. I'm hoping that someone can help me because I think this would be a nice solution that's extensible for others to use for different purposes.

    Thank you!
    Last edited by dklein11; 07-28-2015 at 11:55 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Use VBA to add file names, file sizes and images (if jpg or png) to cells and re-size

    Hello dklein11,

    Welcome to the Forum!

    I have constructed 2 macros One to list the files, types, size, and dimensions. The other is to provide you with a list of available file details and the index number of each. I have included this in case the information returned is not correct. When Windows changed from XP to 2007, some of these indices were changed and new ones were added.

    You can change the folder path and the where the output will go in the first macro. They are marked in blue.

    Macro to List JPG, PDF, PNG, and PPT Files
    Please Login or Register  to view this content.
    Macro to List Index Numbers and Detail Descriptions
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    06-20-2015
    Location
    US
    MS-Off Ver
    2013
    Posts
    11

    Re: Use VBA to add file names, file sizes and images (if jpg or png) to cells and re-size

    Thank you!! I'll try this tonight.

  4. #4
    Registered User
    Join Date
    06-20-2015
    Location
    US
    MS-Off Ver
    2013
    Posts
    11

    Re: Use VBA to add file names, file sizes and images (if jpg or png) to cells and re-size

    Thanks again.

    This is great. But it seems to be missing the image.

    It would be great for each file in the folder that is a picture, to insert the picture in column E, set the row height to 80 and set the image height to 70.

    Is this possible in VBA?
    Thanks!
    Dave

  5. #5
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Use VBA to add file names, file sizes and images (if jpg or png) to cells and re-size

    Hi -

    You can play around with this to show the image in the cell. just add a condition on your code if it is an image.

    Please Login or Register  to view this content.

    event

  6. #6
    Registered User
    Join Date
    10-16-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    1

    Re: Use VBA to add file names, file sizes and images (if jpg or png) to cells and re-size

    This was great. Thanks for the help. I'm new to vba (today). Any suggestions on how to loop the final post for multiple files and also how to pull in image tags and other relevant info. Really appreciate any other you can offer. Cheers Adam

+ 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. import file names from images
    By visionwindowfilms in forum Excel General
    Replies: 15
    Last Post: 05-07-2014, 05:54 AM
  2. Questions about file size & Embedded Images
    By topaz99 in forum Excel General
    Replies: 2
    Last Post: 12-04-2013, 08:27 AM
  3. Match 1400 file Names With Images In Excel
    By Melodious in forum Excel General
    Replies: 0
    Last Post: 07-17-2012, 09:48 AM
  4. Reducing file size after removing images
    By 6StringJazzer in forum Excel General
    Replies: 0
    Last Post: 12-07-2011, 02:37 PM
  5. images show based of file names for adjucent cells
    By Seth42 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-06-2007, 11:21 AM
  6. Reduce the file size of Word file by removing all images in it
    By RosH in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-22-2006, 01:15 AM
  7. Import file size and file names from a directory
    By zahid in forum Excel General
    Replies: 1
    Last Post: 02-07-2006, 09:35 AM
  8. Replies: 1
    Last Post: 02-02-2005, 09:06 AM

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