View Single Post
 
Old 02-24-2017, 03:31 PM
romanticbiro romanticbiro is offline Windows 7 32bit Office 2003
Advanced Beginner
 
Join Date: Feb 2014
Posts: 42
romanticbiro is on a distinguished road
Question handle textbox, pictures, and all kind of shapes

hello dears

i found this macro which remove textbox and rewrite its content in body text,
but i need to develope it more to make the same in opictures or other shapes
(sometimes people put picture in word and type text on it and this make problem for me)

Code:
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
please help me if you have another idea.
thanks

Last edited by macropod; 02-24-2017 at 08:21 PM. Reason: Added code tags
Reply With Quote