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
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