how to delete(or convert into textframe) the linked text boxes without deleting the text on that page using VBA macro

Hi fellas,

I do have a word file which has the linked text boxes. This file is created based on the concept from the following link:

http://office.microsoft.com/en-in/word-help/flow-text-side-by-side-with-linked-text-boxes-HP005189566.aspx

Now the content of file is flow through the document as we want it for the visual presentation. But here the problem 

starts, now that same file wants to be used for the xml conversion. 

Now I have to remove the text boxes but the content of that particular text box should be on that place only.

For example, 

How can I remove the linked text boxes  using the VBA macro. Any help will be grateful.

Thanks in advance.

Answer
Answer

Thanks for your reply fellas, 

I'm sorry for the delay in reply. I have tried both of your methods, it was working good. But I forgot to mention that I wanted each text boxes' text should be placed in the same  order of text boxes (Some text boxes are un-linked which is placed in between the linked text boxes). We came up with the following macro that would read the text box's name from a xml and copy the text range, then place it in a new file. Once again Thank you fellas. 

The following is the macro which we came up with

Sub ExtracttextboxRangetext()
    Dim shp As Shape
    Dim oRngAnchor As range
    Dim sString As String
    Dim xmldoc As MSXML2.DOMDocument
    Dim oXmlNode As MSXML2.IXMLDOMNode
    Set xmldoc = New MSXML2.DOMDocument
    Set doc1 = ActiveDocument
    Set doc = Documents.Add 'create a new document
    doc1.Activate
    Dim j As Integer
    xmldoc.async = False
  If xmldoc.Load("C:\Users\Textframe\Output.xml") = True Then
    Set iList = xmldoc.SelectNodes("//Measurements/TextFrame")
    For Each iNode In iList
    shapeNamFrmXml = iNode.Attributes.getNamedItem("id").Text
        For Each shp In ActiveDocument.Shapes
            If shp.name = shapeNamFrmXml Then
                shp.textframe.TextRange.Select
                pageNum = Selection.Information(wdActiveEndPageNumber)
                MsgBox (pageNum)
                Selection.range.Copy
                doc.Activate
                doc.range.Select
                Selection.EndKey Unit:=wdStory
                Selection.InsertBefore (Chr(13))
                Selection.PasteAndFormat (wdPasteDefault)
                Selection.InsertBefore (Chr(13))
                doc1.Activate
            End If
        Next shp
    Next iNode
    End If
End Sub

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 5, 2021 Views 484 Applies to: