TMG-L Archives

Archiver > TMG > 2006-09 > 1157125918


From: Stuart Armstrong <>
Subject: Re[2]: [TMG] Word Macro to resize exhibits
Date: Fri, 1 Sep 2006 09:51:58 -0600
References: <978642106.20060831000406@aros.net> <000501c6cd1a$bd0d5850$6401a8c0@Dell2003>
In-Reply-To: <000501c6cd1a$bd0d5850$6401a8c0@Dell2003>


Donald,

I frequently find VBA lines that don't work. When I wrote the macro
below, the second input box statement was completely ignored until I
added the DIM statements. I'm used to Pascal which is fussy about
pre-defining variables and complains whenever there is a type mismatch
or not enough memory allocated for variables. So the DIM statement
was a guess, and I still don't know why the InputBox function, which
expects a string, will work with a variable that's defined as an
integer. In Pascal you'd have to convert it. VBA must be doing
something behind the scenes.

Perhaps there is a similar problem with LockAspectRatio. Maybe it
requires something else in the module that makes it work or not.


> BTW, your reply address is set so responses to your postings are not sent to
> TMG-L.
I thought that was a list function. Will look into it.


Thursday, August 31, 2006, 10:30:13 AM, you wrote:
> Well, using the Macro Recorder works for me - I tried it in order to
> validate the procedure I put in the message. My Lock Aspect Ratio box was
> checked by default and when the macro runs the aspect ratio is indeed
> maintained. So the simpler procedure using the recorder shoud work for
> others also, and I don't know why it didn't for you.

> That said, writing the more comprehensive macro directly in Visual Basic as
> you have specified below should be useful to TMG users, including me, who
> want to scan a document and automatically resize the pictures.

>> -----------------------------------------------------
>> Sub ResizePhotos()
>> Dim PreferredHeight As Integer
>> Dim MaximWidth As Integer
>> PreferredHeight = InputBox("Enter height in points
>> (72pts/in, 28pts/cm)",,198)
>> MaximWidth = InputBox("Enter maximum allowable width in
>> points",,396)
>> For Each ishape In ActiveDocument.InlineShapes
>> With ishape
>> ImageWidth = .Width
>> ImageHeight = .Height
>> NewHeight = PreferredHeight
>> NewWidth = Round(NewHeight * ImageWidth / ImageHeight)
>> If NewWidth > MaximWidth Then
>> NewWidth = MaximWidth
>> NewHeight = Round(NewWidth * ImageHeight / ImageWidth)
>> End If
>> .Height = NewHeight
>> .Width = NewWidth
>> End With
>> Next
>> End Sub
>> -----------------------------------------------------
Note: 2 of the lines above are split with CR's that may have to be
removed for the macro to work.
--
Best regards,
Stuart mailto:


This thread: