Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Select all images via VBA code or else...

Posted on 2006-11-01
10
Medium Priority
?
705 Views
Last Modified: 2008-02-01
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.
0
Comment
Question by:Non-Linear
  • 5
  • 3
  • 2
10 Comments
 
LVL 21

Expert Comment

by:Eric Fletcher
ID: 17849575
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.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 17849584
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.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 17849635
Well done, Eric. I'm leaving the next one for you. It's about styles.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 21

Expert Comment

by:Eric Fletcher
ID: 17850179
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.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 17851811
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
0
 

Author Comment

by:Non-Linear
ID: 17856864
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.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 1000 total points
ID: 17857080
This macro to run on the result document might help, though I'm not sure if it matches your criterion about being visual.

Sub ResizePictures()
    Dim ilsh As InlineShape
    For Each ilsh In ActiveDocument.InlineShapes
         
        'ilsh.LockAspectRatio = msoTrue
        'Locking the aspect ratio doesn't seem to work on my system, so I set it to false
        'and adjust both height and width
        ilsh.LockAspectRatio = msoFalse
       
        ilsh.Width = ilsh.Width / 2
        ilsh.Height = ilsh.Height / 2
    Next ilsh
End Sub
 
0
 

Author Comment

by:Non-Linear
ID: 17857655
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.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 17857832
That's ironic. My code had the opposite problem.
0
 

Author Comment

by:Non-Linear
ID: 17858074
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question