In this article, we want to show you 2 quick and easy to use methods to extract texts from text boxes in your Word document.
From time to time, we can get a Word file containing a large number of text boxes. Usually, there will be texts or relative contents inside those boxes. Then there can be the need to get only the texts inside instead of keeping the whole text box.
Certainly, it’s quick to retrieve words within one single text box simply by copying the text out and pasting it somewhere else. However, when it comes to hundreds of them, we’d better learn some quick tips to get the job done.
Method 1: Use the “Selection Pane”
- First and foremost, click “Home” tab.
- Then click “Select” icon in “Editing” group.
- Next, on the drop-down menu, choose “Selection Pane”.
- Now on the right side of the screen, you can see all text boxes visible on the pane.
- Press “Ctrl” and click those text box names on the pane one by one to select them all.
- And move to lay cursor on one of the box line and right click.
- On the list-option, click “Copy”. Now if you won’t need those boxes anymore, just press “Delete”.
- Next click “Start” to view the Windows menu.
- Choose “WordPad” and open it.
- Then click “Paste” to get all texts from the text boxes.
- Next, select all texts and right click to choose “Copy”.
- Now open a new Word document and right click to choose “Keep Text Only” to get the text.
Method 2: Use VBA Codes
As you may see, even with the first method, you can’t avoid selecting all text boxes. In case some of you just hate such labor work, here we are to offer you the way to run a macro. With method 2, you can extract all texts in one go and have the text boxes deleted.
- Firstly, press “Alt+ F11” to open the VBA editor.
- Secondly, click “Normal” and then “Insert”.
- Next choose “Module” to insert a new one.
- Then double click on the module name to open the editing area.
- Paste the following codes and click “Run”:
Sub DeleteTextBoxesAndExtractTheText() Dim nNumber As Integer Dim strText As String ' Delete all textboxes and extract the text from them With ActiveDocument For nNumber = .Shapes.Count To 1 Step -1 If .Shapes(nNumber).Type = msoTextBox Then strText=strText& .Shapes(nNumber).TextFrame.TextRange.Text & vbCr .Shapes(nNumber).Delete End If Next End With ' Open a new document to paste the text from textboxes. If strText <> "" Then Documents.Add Template:="Normal" ActiveDocument.Range.Text = strText Else MsgBox ("There is no textbox.") End If End Sub
Here is what you are likely to get:
Cope with Wrecked Word Files
Word is prone to errors and hence a frequent victim to corruption. Therefore, you have to manage your documents properly to protect them from damage. For once they getting corrupted, you will face the risk of losing them permanently. Then you will have to use the corrupted Word data recovery tool.
Author Introduction:
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including Excel file error recovery tool and pdf repair software products. For more information visit www.datanumen.com
Wow, superb weblog structure! How lengthy have you ever been blogging for?
you make running a blog glance easy. The entire look of your website is magnificent, as well as the content material!
You can see similar: Zabawka.shop and here Zabawka.shop
1
This piece of writing gives clear idea for the new users of blogging, that in fact how to do running a blog.
sabertooth labs delta 8
physicallyfitpersonalfitnesstraining.com
Corrected code:
Sub DeleteTextBoxesAndExtractTheText()
Dim nNumber As Integer
Dim strText As String
‘ Delete all textboxes and extract the text from them
With ActiveDocument
For nNumber = .Shapes.Count To 1 Step -1
If .Shapes(nNumber).Type = msoTextBox Then
strText = strText & .Shapes(nNumber).TextFrame.TextRange.Text & vbCr
.Shapes(nNumber).Delete
End If
Next
End With
‘ Open a new document to paste the text from textboxes.
If strText “” Then
Documents.Add Template:=”Normal”
ActiveDocument.Range.Text = strText
Else
MsgBox (“There is no textbox.”)
End If
End Sub
Select all the text boxes.
Past it into a XLS worksheet.
Copy all the cells with the text.
Paste the copied cells back in the Document.
All the text is now in a table.
Convert the table to text.
This works great. What would you change to get the text to extract in the same order as they appear in the document?
Note there’s an error in the code. You’ve forgotten the space between strText and the ampersand that follows.