Thread: [Solved] Formatting picture
View Single Post
 
Old 11-20-2020, 04:50 PM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Step through this version of your original code. It won't hang because the inlineshape is no longer selected:


Code:
Sub Whine1()
Dim oILS As InlineShape
  With Selection
    If .InlineShapes.Count <> 1 Then Exit Sub
    Set oILS = .InlineShapes(1)
    .Collapse wdCollapseEnd
  End With
  With oILS.Borders
    .Enable = True
    .OutsideLineWidth = wdLineWidth300pt
    .OutsideLineStyle = wdLineStyleSingle
    .OutsideColorIndex = wdBlack
  End With
End Sub

and this, it will format all the inlineshapes and shapes in the main text storyrange of the document.


Code:
Sub WhineII()
Dim oILS As InlineShape
Dim oShp As Shape

  For Each oILS In ActiveDocument.InlineShapes
    With oILS.Borders
      .Enable = True
      .OutsideLineWidth = wdLineWidth300pt
      .OutsideLineStyle = wdLineStyleSingle
      .OutsideColorIndex = wdBlack
    End With
  Next oILS
  For Each oShp In ActiveDocument.Shapes
    With oShp
       .Line.ForeColor.RGB = RGB(0, 0, 0)
       .Line.Weight = 4
       .Line.DashStyle = msoLineSolid
    End With
  Next
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote