TMG-L Archives

Archiver > TMG > 2006-09 > 1158018988


From: "Bob Berg" <>
Subject: [TMG] Word Macro to resize exhibits (and restore links)
Date: Mon, 11 Sep 2006 18:56:28 -0500
In-Reply-To: <1638571010.20060901095158@aros.net>


The macro to set resize works fine, does anyone know how to make a macro to
restore the image links after importing from TMG to MS word? The macro
recorder doesn't seem to work at all in the circumstance. I would like to
add to the resize macro to have one exhibit macro.

Bob Berg

-----Original Message-----
From: Stuart Armstrong [mailto:]
Sent: Friday, September 01, 2006 10:52 AM
To:
Subject: Re[2]: [TMG] Word Macro to resize exhibits

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: