?
Solved

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

Posted on 2010-11-22
7
Medium Priority
?
334 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 2000 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

770 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