Quote:
Originally Posted by gmayor
If you want to centralise the image it needs to be an inline shape. You can convert it, if you must, after you have centred it.
|
That's not necessary, actually:
Code:
Sub InsertPic()
Dim strFile As String, iShp As InlineShape, Shp As Shape, Rng As Range
On Error Resume Next
With Dialogs(wdDialogInsertPicture)
.Display
If .Name <> "" Then
strFile = .Name
Else
Exit Sub
End If
End With
Set Rng = Selection.Range: Rng.Collapse wdCollapseEnd
Set iShp = ActiveDocument.InlineShapes.AddPicture(strFile, False, True, Rng)
Set Shp = iShp.ConvertToShape
With Shp
.LockAnchor = True
.LockAspectRatio = msoTrue
.Height = .Height / 2
.RelativeVerticalPosition = wdRelativeVerticalPositionLine
.Top = 0
.RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
.Left = wdShapeCenter
End With
Set Rng = Nothing: Set iShp = Nothing: Set Shp = Nothing
End Sub
puff: Multiple shapes can also be inserted this way, but the issue that then needs to be addressed is how their relative vertical positions are to be managed. See also:
https://www.msofficeforums.com/word-...html#post47919