paste and change width of object

I

Ivano

Hi,
I have a area already selected in Excel copied to my clipboard and have the
cursor in the spot within Word where I want it to go but I ant to run code to
do the following:
paste special > Link > MS Excel Worksheet Object
change the width to 7.5" (wich should be 540 pts)

Thanks,
 
I

Ivano

This is what I have come up with:
Sub Macro1()

Selection.PasteSpecial Link:=True, DataType:=wdPasteOLEObject,
Placement:= _
wdInLine, DisplayAsIcon:=False
Selection.InlineShapes(1).width = 540

End Sub

But I get erro messages when it tries to adjust the width. So I go back
into the Word document click the object and run the last line of code
"Selection.Inline.... " but all that does is squishes it but doesn't keep the
aspect ratio. Although all the objects will have the same width (7.5") they
will not all be the same height. That's why I need the aspect ratio turned
 
H

Helmut Weber

Hi Ivano,

here and now, lockaspectratio seems to be of no use.

So do it yourself.

Sub Test444091()
' selection.InlineShapes(1).LockAspectRatio = msoTrue 'no use
Dim f As Single ' factor
With Selection.InlineShapes(1)
f = InchesToPoints(2) / .Height
.Height = .Height * f
.Width = .Width * f
End With
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top