View Single Post
 
Old 03-06-2023, 03:47 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,166
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