Link to home
Start Free TrialLog in
Avatar of Non-Linear
Non-Linear

asked on

Select all images via VBA code or else...

Hi, I have a big word document with a lot of same images. I want to select all images and redimension them with the same way and do not redimension each one of them (because they are about 14.000!!). I think that this can be done via vba code (macro) but how? Else, is there other method? The doc is the result of a mail merge with different image (but with the same wrong dimensions) in each page and there isn't a way to change the dimension to the image merge field before the merge.
Avatar of Eric Fletcher
Eric Fletcher
Flag of Canada image

If the entire document is being generated by mail merge, and you want all images to be the same dimension, you can constrain the image size by setting them within a table in the merge document (even a one-cell table will do) and turning off the "Automatically resize to fit contents" table option (Options... button of Table Properties). Incoming images will be sized to fit the table.

If possible, consider using the INCLUDEPICTURE field with the \d switch to insert the images as a link to the originals. With that many images, inserted images will make the file very large; as linked images, it would be quite manageable.
How many images are there in the Main document? It might be easier to change the dimensions in the Main document and then rerun the merge.
Well done, Eric. I'm leaving the next one for you. It's about styles.
LOL Graham! We must operate on very similar schedules -- even though there is a big gap in our time zones. I have EE open in a multi-tabbed Firefox browser on my right monitor, and pop over to it every so often as I work in Word (or whatever) on the left one.

Non-Linear: When you say "a lot of same images" in your question, do you mean the 14K images are not 14K different ones? If so, inserting them as links will be even more efficient. As an alternative approach, is there any way you can "pre-process" the images to resize them and save them with the same name into a different directory? Many image management programs can do this as a batch routine. This way, you would have them in the size you want, but would not be altering the originals.
It seems so, Eric.

I try to service questions that I have already commented on before looking for fresh ones. Also, today I was trying to fix my own 'missing NTLDR' problem, so I was even later than usual in getting started. My Firefox is open in my left monitor.

Non-Linear, please excuse our by-conversation.
We haven't answered your question directly.

It would be possible to devise a macro to do that, but it may not be the best way and more details would be needed
Avatar of Non-Linear
Non-Linear

ASKER

Erick's idea about one cell table smells good I'll try it...
Graham...I have only one image in the main document and after the merge the image is different for each one page. I can't change the dimensions in main document because there isn't an image frame or box that I put the image. I use the {INCLUDEPICTURE {MERGEFIELD Path}} and this is not visual. I need a vissually way to change the dimension in the main document (that will affect the merged document later) or in the merged document.I think that the Erick's tricky idea is good but I have to try first and I'll reply soon...
The second idea about pre-process the images is good but this is not a visually way incorporated to the word document so that I can see the result immediately. If the pre-process is not the right then I have to pre-process again and again...because I can't know how these changes will appear in the document.
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok I think that we are in a good way...
Look...The idea with cell is working (the same with a text box) but there is a problem with the Lock aspect ratio property of the images. This property is checked by default and when I change the height of the cell (or text box) then the height of the image that appear changes but also it changes the width of the image and this is not what I want.
That's ironic. My code had the opposite problem.
Yes...it is
But I think that I will solve my problem exactly as I want and Graham is the reason...or the code that Graham has written. I want to change the width and height of all images one pixel at a time independently. I will create four macros with a button for each one and with this way I will have visually results...I will try and I will be back