Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-20-2023, 01:52 PM
laith93 laith93 is offline Convert Text Boxes to Normal Text in Word Using VBA Code Windows 10 Convert Text Boxes to Normal Text in Word Using VBA Code Office 2019
Competent Performer
Convert Text Boxes to Normal Text in Word Using VBA Code
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Default Convert Text Boxes to Normal Text in Word Using VBA Code

Hi,
Please how to convert already text boxes in Word to normal or plain text, sometimes, I copied text boxes from PowerPoint.
I used many codes on the internet for this purpose, but all does not fulfill my need, such as
Removing All Text Boxes In a Document (Microsoft Word)
Any fix, suggestion, please?
Use demo file



Thanks
Attached Files
File Type: docx demo.docx (25.7 KB, 5 views)
Reply With Quote
  #2  
Old 03-06-2023, 03:47 PM
Guessed's Avatar
Guessed Guessed is offline Convert Text Boxes to Normal Text in Word Using VBA Code Windows 10 Convert Text Boxes to Normal Text in Word Using VBA Code Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

The basic principle is as follows
Code:
Sub FlattenTextBoxes()
  Dim shp As Shape, iShp As Integer, sString As String
  For iShp = ActiveDocument.Shapes.Count To 1 Step -1
    Set shp = ActiveDocument.Shapes(iShp)
    If shp.TextFrame.HasText Then
      sString = shp.TextFrame.TextRange.Text
      shp.Anchor.InsertBefore sString
      shp.Delete
    End If
  Next iShp
End Sub
Your sample file had all the text boxes anchored to the same paragraph and the text is getting put into the doc in reverse order. This single anchor makes it more complicated to get the resulting text in the same order as it appeared on the page. Perhaps this isn't an issue in your Actual documents - the code would likely need to be a lot more complicated to replicate the order of the original text.
I'm not sure if the numbering order uses Z-Order, creation order or physical location on the page.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 03-09-2023, 11:51 PM
laith93 laith93 is offline Convert Text Boxes to Normal Text in Word Using VBA Code Windows 10 Convert Text Boxes to Normal Text in Word Using VBA Code Office 2019
Competent Performer
Convert Text Boxes to Normal Text in Word Using VBA Code
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
The basic principle is as follows
Code:
Sub FlattenTextBoxes()
  Dim shp As Shape, iShp As Integer, sString As String
  For iShp = ActiveDocument.Shapes.Count To 1 Step -1
    Set shp = ActiveDocument.Shapes(iShp)
    If shp.TextFrame.HasText Then
      sString = shp.TextFrame.TextRange.Text
      shp.Anchor.InsertBefore sString
      shp.Delete
    End If
  Next iShp
End Sub
Dear Andrew,
Thanks so much for this great help
The basic reason for this appearance is when I convert a PowerPoint file (in pdf format downloaded from the net) to ppt again, every line is converted to a textbox, after running your macro, it flattened all the textboxes to standard plain text.
Now everything is ok, although it requires returning each line to its corresponding paragraph.

However, Thanks again with my respect, you helped me and saved my time.
Best Wishes
Reply With Quote
Reply

Tags
vba, word vba, word vba code



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Text Boxes to Normal Text in Word Using VBA Code Convert all equations to "Normal Text" b0x4it Word VBA 16 02-14-2023 03:52 AM
Convert Text Boxes to Normal Text in Word Using VBA Code Creating and Referencing Drop Down Text Boxes in VBA code cjkmarx Word VBA 1 12-12-2016 03:20 PM
Convert Text Boxes to Normal Text in Word Using VBA Code Word 2013 Text boxes on everything, can't select across multiple boxes 1Kurgan1 Word 2 10-31-2016 01:20 AM
Convert Text Boxes to Normal Text in Word Using VBA Code Drawing lines between text boxes which have actual text within the text boxes RHODIUM Word 6 10-01-2016 04:43 PM
Converting normal text boxes into placeholders? thousandred PowerPoint 0 12-08-2010 09:59 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:50 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft