Insert Image Resize with Link to File

P

Paul

Hi
I am trying to create a macro which will allow me to insert an image
and resize it to a given percentage of the orginal size of the image
(amongst other things). Currently the following piece of code is
working correctly:

Dim imagePath As String
Selection.TypeParagraph

With Dialogs(wdDialogInsertPicture)
If Not .Display Then Exit Sub
imagePath = .Name
Selection.InlineShapes.AddPicture _
fileName:=imagePath, _
LinkToFile:=False, _
SaveWithDocument:=True
End With

Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend

Selection.InlineShapes(1).ConvertToShape
Selection.ShapeRange(1).ScaleHeight 0.02, msoCTrue
Selection.ShapeRange(1).ScaleWidth 0.02, msoCTrue
Selection.ShapeRange(1).ConvertToInlineShape

The problem is that I also want the LinkToFile to be set to true -
LinkToFile:=True - however when doing this, the line
Selection.InlineShapes(1).ConvertToShape causes the image to become
unselected and therefore when the line
Selection.ShapeRange(1).ScaleHeight 0.02, msoCTrue is executed, get
the error "The index into the specified collection is out of bounds"

Any one got any ideas? Any help is greatly appreciated
Cheers
Paul
 

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