I want to create an Excel workbook that will read lists of items from another workbook and create new worksheets in our new workbook populated with images and their titles based on the contents of the other workbook.
To explain this further:
I have a workbook with several worksheets. We'll call the workbook BookA and it's sheets SheetAA, SheetAB and SheetAC for reference.
Each of these worksheets has a list of items in column A, starting at cell A15.
Each item in this list may have up to three images associated with it (though there may also be none).
All images for all sheets are stored in the same folder for a given version of BookA, and all images are of the same dimensions.
Image names are based on the item name with one of three postfixes, for example:
'item_name_001' may have images named 'item_name_001_P.jpg', 'item_name_001_C.jpg' or 'item_name_001_S.jpg'. The postfixes are always an underscore followed by 'P', 'C' or 'S' and the .jpg file extension.
For each of the desired sheets in BookA, I want to run down the item list in order and identify if each of these associated images exist in the folder. If it does, I want to import it to the new workbook in a correspondingly named new sheet.
For these new sheets, the image layout is important. The images must span 3 columns. The first image should be placed in cell A1, the second in B1 and the third in C1. Where more than one image exists for an item, they should be ordered 'P', 'C', then 'S' (from the image name postfix). If there are only one or two images for a given item, then the next item's images should immediately follow it in the row until we reach our maximum of column 3, then wrap down to the second row below.
Each image also requires the image name to be placed in the cell immediately below it.
Thus we have 2 rows of 3 columns for each row of items - a row of 3 images with a row of 3 image names underneath. That is:
Cells A1-C1 contain 3 images.
Cells A2-C2 contain 3 image titles.
Cells A3-C3 contain 3 images.
Cells A4-C4 contain 3 image titles.
... and so on until the end of a sheet's list of items.
The image dimensions are constant, but do need scaling from the original size. The ideal is for them to remain 8.5cm height while maintaining their aspect ratio (the current manually created version I'm looking at has an image size of 8.49cm x 11.32cm, though no doubt there's some rounding to that).
Currently on my manually created sheets, a row height of 240 for the images and 15 for the titles looks about right for Arial 8 point text for the titles.
I'd like to be able to select BookA's title and location, and also the source directory for the images to be used. Having done so, our new workbook should generate corresponding SheetAA, SheetBB, SheetCC populated with our images in the format above. No other information is needed on these sheets.
The explanation sounds more complex than it really is when you break it down but I wanted to be as clear and specific as possible. Sadly my VBA skills aren't quite up to this as I've not used it in years.
Note the reason for my wanting a new workbook to generate these populated sheets is to avoid putting any code into the original source document, that needs to remain 'clean'.
Thanks in advance for any assistance with this, it will be a huge timesaver for me.
Bookmarks