Created
February 6, 2023 12:41
-
-
Save githubyouser/28e8f56ac59697abeee4a05d88afd94d to your computer and use it in GitHub Desktop.
Word VBA: Convert text boxes to plain text
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
'https://answers.microsoft.com/en-us/msoffice/forum/all/removing-text-box-from-word-document-without/a4d02b2f-d168-48dc-960b-4a45cbe79d86 | |
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 | |
'https://eileenslounge.com/viewtopic.php?p=28255#p28255 | |
If .TextFrame.HasText = True Then | |
Set RngShp = .TextFrame.TextRange | |
RngShp.InsertParagraphBefore | |
RngShp.InsertBefore "@@@@@" | |
RngShp.InsertParagraphAfter | |
RngShp.InsertAfter "@@@@@" | |
RngShp.InsertParagraphAfter | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment