Created
July 12, 2017 13:13
-
-
Save rabarbara/303e724e96f6220dc4ef54324f03d821 to your computer and use it in GitHub Desktop.
Removing All Text Boxes In a Document
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ' Source: https://wordribbon.tips.net/T009169_Removing_All_Text_Boxes_In_a_Document.html | |
| Sub RemoveTextBox2() | |
| Dim shp As Shape | |
| Dim oRngAnchor As Range | |
| Dim sString As String | |
| For Each shp In ActiveDocument.Shapes | |
| If shp.Type = msoTextBox Then | |
| ' copy text to string, without last paragraph mark | |
| sString = Left(shp.TextFrame.TextRange.Text, _ | |
| shp.TextFrame.TextRange.Characters.Count - 1) | |
| If Len(sString) > 0 Then | |
| ' set the range to insert the text | |
| Set oRngAnchor = shp.Anchor.Paragraphs(1).Range | |
| ' insert the textbox text before the range object | |
| oRngAnchor.InsertBefore _ | |
| "Textbox start << " & sString & " >> Textbox end" | |
| End If | |
| shp.delete | |
| End If | |
| Next shp | |
| End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment