View Single Post
 
Old 08-23-2017, 01:44 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,370
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could use something along the lines of:
Code:
Sub Demo()
Dim t As Single, l As Single, tRel As Single, lRel As Single
With Selection
  If .InlineShapes.Count = 1 Then
    .InlineShapes(1).Range.Cut
    .PasteSpecial DataType:=15
    .End = .End + 1
    With .InlineShapes(1).Borders
      .Enable = True
      .OutsideLineStyle = wdLineStyleSingle
      .OutsideLineWidth = wdLineWidth225pt
      .OutsideColorIndex = wdBlack
    End With
  ElseIf .ShapeRange.Count = 1 Then
    With .ShapeRange(1)
      tRel = .TopRelative
      t = .Top
      lRel = .LeftRelative
      l = .Left
      .Anchor.Cut
    End With
    .PasteSpecial DataType:=15
    .End = .End + 1
    With .InlineShapes(1).Borders
      .Enable = True
      .OutsideLineStyle = wdLineStyleSingle
      .OutsideLineWidth = wdLineWidth225pt
      .OutsideColorIndex = wdBlack
    End With
    .InlineShapes(1).ConvertToShape
    With .ShapeRange(1)
      .TopRelative = tRel
      .Top = t
      .LeftRelative = lRel
      .Left = l
    End With
  End If
End With
End Sub
As for your compression requirements, though, your "so that its size dimensions are reduced" is ambiguous and there's no VBA access to Word's image compression, per se.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote