Solved

Select all images via VBA code or else...

Posted on 2006-11-01
10
676 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:EricFletcher
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
 
LVL 21

Expert Comment

by:EricFletcher
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now