Erase text boxes in Word but retain text and formatting (macro)

spiros

  • Administrator
  • Hero Member
  • *****
    • Posts: 854551
    • Gender:Male
  • point d’amour
Erase text boxes in Word but retain text and formatting

Code: [Select]
Sub EraseTextBoxes()
Dim RngDoc As Range, RngShp As Range, i As Long
With ActiveDocument
  For i = .Shapes.Count To 1 Step -1
    With .Shapes(i)
      If .Type = msoTextBox Then
        Set RngShp = .TextFrame.TextRange
        RngShp.End = RngShp.End - 1
        Set RngDoc = .Anchor
        RngDoc.Collapse wdCollapseEnd
        RngDoc.FormattedText = RngShp.FormattedText
        .Delete
      End If
    End With
  Next
End With
End Sub

Removing text box from word document without removing the text inside - Microsoft Community
Removing All Text Boxes In a Document (Microsoft Word)
« Last Edit: 09 Aug, 2021, 21:17:58 by spiros »


 

Search Tools