Solved

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

Posted on 2010-11-22
7
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

687 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