View Single Post
 
Old 07-03-2014, 11:39 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,371
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

The picture insertion behaviour is primarily determined by your Word options. Under File|Options|Advanced>Cut, Copy & Paste>Insert/Paste pictures as, you can choose 'In-line with text' or one of the floating formats. Only the 'In-line with text' option will give you the behaviour desired for your macro. Even with that option, however, if you drag & drop an image that's in a 'floating' format from another document, or from another location in the same document, the format won't change to 'In-line with text' at the destination.

Try the following revision to your code. Do note that any Shape objects that get converted to InlineShapes are liable to change position to wherever they are anchored.

Code:
Sub AfbeeldingImporteren()
Dim i As Long
With Selection
  'Convert floating shapes to inline
  For i = .ShapeRange.Count To 1 Step -1
    .ShapeRange(i).ConvertToInlineShape
  Next
  'process all InlineShapes
  For i = 1 To .InlineShapes.Count
    With .InlineShapes(i)
      ' retain aspect ratio
      .LockAspectRatio = msoTrue
      ' set width to 225 px
      newWidth = 225
      .Width = newWidth
      ' Add Borders
      With .Line
        .Weight = 0.75
        .DashStyle = msoLineSolid
        .Visible = msoTrue
        .ForeColor.RGB = RGB(0, 0, 0)
      End With
    End With
  Next
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote