Solved

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

Posted on 2010-11-22
7
323 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

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

20 Experts available now in Live!

Get 1:1 Help Now