Macro Help. Copying Text From Draw to Word

I'm having trouble finding information on how to control Microsoft Word with CorelDraw macros. I'm trying to create a Macro that can copy text from CorelDraw into Word. Ideally it will paste this text into text boxes while retaining as much formatting as possible. 

I'm using X4. The initial part of the script I've written finds text objects in Draw that contain a certain word. All the text within these text objects needs to be copied. The formatting (bold, italics, size, leading) may vary throughout the text range. Retaining the formatting may be complicated but if someone knows a way to copy the text into Word text boxes it will be a good start.

Thanks for any help.

Parents
No Data
Reply
  • HolyMacro, 

    There are several ways you could do this. If you selected the line of text you can create a TextBox from the selection like this:

    Sub TestBoxwithSelection()
        If Selection.Type = wdSelectionNormal Then
            Selection.CreateTextbox
        End If
    End Sub
    

    Or you could actually create the TextBox and then place your text into it:

    Sub AddingTextbox()
        Dim box As Shape
        
        Set box = ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 50, 50, 100, 100)
        box.TextFrame.TextRange.Text = "Sample Text, Sample Text, Sample Text"
    End Sub
    

    Hope that helps,

    -Shelby

Children