Solved

Macro or IF statement coding required for mergedfields document to resize multiple images

Posted on 2010-11-22
7
324 Views
Last Modified: 2012-05-10
This post relates similarly to a previous one here:
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Word/Q_26626676.html

The above solution works great, however, this documents layout is different therefore the macro does not work as i'd like it to.

This document lists 3 properties per page and contains 1 picture of each property and ICONS to represent the property details e.g. property type, location.

When I choose to resize the property images in this document the small images which are meant to be more like icon indicators also resize, this does not happen in my previous post but I expect its the layout of the document which causes this.

I have attached a test document but had to remove sensitive data


test-x3.doc
0
Comment
Question by:auraorange
  • 4
  • 2
7 Comments
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
ID: 34194311
The height of your "ICONS" are 41.25 cm. Add an If statement to address shapes greater than that.

For Each oILShp In ActiveDocument.InlineShapes
With oILShp
If .Height > 41.5 Then
.Height = AspectHt(.Width, .Height, _
CentimetersToPoints(11))
.Width = CentimetersToPoints(11)
End If
End With
Next
End Sub

Flyster
0
 
LVL 2

Author Comment

by:auraorange
ID: 34194694
Thank you flyster for the feedback

Could you advise me where to put this code?

Regards, Aura
0
 
LVL 2

Author Comment

by:auraorange
ID: 34195857
Prior to an update later from yourself hopefully.

Another problem I face is that some property pictures also initially come through very small and this could conflict with the above code.

Another thought I have had is that currently the property pictures are the small "icons" are classed as JPG's, I could change the icon sized images to .PNG or another format if this would make it possible to exclude them via some coding.

Thanks, mat
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Expert Comment

by:Flyster
ID: 34198528
The code I provided was a snippet from the one you refered to in your post. The IF statement comes right after "With oILSHp." As all your ICONS are 41.25 cm, you can try changing the code to "IF .Height <> 41.25 Then". This will ignore all shapes with a height of 41.25 cm. As long as your property pictures are not 41.25 cm also, they should be reformated by the code.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 34200700
Icons 42.25 cm high?  Remember the max height of a report is 22 ", including top and bottom margins, and any other controls above or below the icons.
0
 
LVL 2

Author Comment

by:auraorange
ID: 34206087
First my apologies:

1) I do not understand the code and when I run the above code I get an error
2) When I look at the icon properties it says the images are 1.46cm * 1.46cm
3) This problem seems to stem from the actual images themselves.  If i can get code or a macro to resize then that would be perfect and the most simple for people to follow (As i need to show staff how to run the merge extracts and the simpler the better

Referring back to there being a problem with the images I mean in terms of their properties.  All of them are sized to 200*150pixels but their sizes vary from about 20kb to over 1mb. I downloaded FastStone image viewer today and this reset all of the images to the same sizes and properties and when i've run the extract again the images have all loaded the correct size!  For me this workaround is ok but the people who have to do this work each week are not as computer literate as myself and using faststone would add another 10 or so points onto the instructions for them to follow.
0
 
LVL 2

Author Closing Comment

by:auraorange
ID: 34309054
Thank you.

I have found that there is an issue regarding inserting multiple jpg images into a word document as word uses a default resolution and resizes image for you, therefore, to complete this task I used FastStone Image Viewer and coverted all images to .GIF, then used adapted version of your code and this worked.  Thanks, mat
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

929 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

17 Experts available now in Live!

Get 1:1 Help Now