View Single Post
 
Old 05-25-2020, 03:08 PM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

You would want to ensure the anchor range paragraph doesn't contain text:

Code:
Public Sub RelaceAllGraphicsWithNothing()
Dim rngStory As Word.Range
Dim lngJunk As Long
Dim lngIndex As Long
Dim oShp As Shape
Dim oPar As Paragraph
  'Fix the skipped blank Header/Footer problem
  lngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryType
  'Iterate through all story types in the current document
  For Each rngStory In ActiveDocument.StoryRanges
    'Iterate through all linked stories
    Do
      SrcAndRplInStory rngStory, "^g^p", ""
      SrcAndRplInStory rngStory, "^g^l", ""
      SrcAndRplInStory rngStory, "^g", ""
      For lngIndex = rngStory.ShapeRange.Count To 1 Step -1
        Set oShp = rngStory.ShapeRange.Item(lngIndex)
        If Len(oShp.Anchor.Paragraphs(1).Range) = 1 Then
          Set oPar = oShp.Anchor.Paragraphs(1)
          oShp.Anchor.Delete
          oPar.Range.Delete
        Else
          oShp.Delete
        End If
      Next lngIndex
      'Get next linked story (if any)
      Set rngStory = rngStory.NextStoryRange
    Loop Until rngStory Is Nothing
  Next
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote