# [SOLVED] A resizing image macro that worked in Word 2003, but not in 2007



## bbint (Aug 29, 2010)

Hi. 
I came across an answer here:
http://www.techsupportforum.com/f57/solved-creating-a-macro-in-word-to-resize-an-image-342723.html

I tried the macro, and it worked perfectly. I had a macro in Word 2003, but it doesn't work in 2007. If any picture is too large, I make it the width of my margins. Some buttons are tiny, and I want to ignore them and not resize them because I don't them to be all large and blurry.

Does anyone know what's wrong with it?


```
Sub ResizeAllbutSmall()
Dim iShp As InlineShape
Dim Shp As Shape
    For Each iShp In ActiveDocument.InlineShapes
        With iShp
            If .Width > CentimetersToPoints(12) Then
                .Height = AspectHt(.Width, .Height, _
                CentimetersToPoints(13.8))
                .Width = CentimetersToPoints(13.8)
            End If
        End With
    Next iShp
    For Each Shp In ActiveDocument.Shapes
        With Shp
            If .Width > CentimetersToPoints(12) Then
                .Height = AspectHt(.Width, .Height, _
                CentimetersToPoints(13.8))
                .Width = CentimetersToPoints(13.8)
            End If
        End With
    Next Shp
End Sub
```
AspectHt gets highlighted in a compile error. "Sub or Function not defined".

Thanks for reading


----------



## RSpecianjr (Jan 20, 2010)

*Re: A resizing image macro that worked in Word 2003, but not in 2007*

Hey bbint,

AspectHT is a different function, a function that isn't in existence. That is why you are getting the error. After a quick google search, looks like you got it from another forum. The private function was:


```
Private Function AspectHt( _
origWd As Long, origHt As Long, _
newWd As Long) As Long
If origWd <> 0 Then
AspectHt = (CSng(origHt) / CSng(origWd)) * newWd
Else
AspectHt = 0
End If
End Function
```
I haven't actually looked at it, so let me know if thats what you needed, or if its still not working.

Thanks,

Robert D. Specian Jr.


----------



## bbint (Aug 29, 2010)

*Re: A resizing image macro that worked in Word 2003, but not in 2007*

Works!

I checked my text document of all my macros for 2003, and I noticed that I did have that private function. I don’t know anything about macros, and I was just transferring procedures 1 at a time to 2007. The code above was just my alteration of an original procedure, and I didn’t see the private function that was sitting underneath that original procedure.

Thanks Robert.


----------



## macropod (Apr 11, 2008)

Hi bbint,

FWIW, I couldn't reply to your PM of a few days ago about this issue as the way you've configured your user settings doesn't allow for the receipt of private messages.

In any event, your problem stemmed from trying to merge code from two sources without appreciating the differences in the way each worked. The AspectHT function was not a part of the code from my post, for which you provided a link.


----------



## bbint (Aug 29, 2010)

No worries macropod.


----------

