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.
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
Shelby, does this work for MSWord or for CorelDraw? My hang up was getting the boxes in Word. Just in case someone else has this issue in the future, I had some help here:
http://www.mrexcel.com/forum/excel-questions/803182-using-macros-control-word-through-excel-other-program.html#post3929768
http://windowssecrets.com/forums/showthread.php/164123-Macro-Help-Creating-Text-Box-in-Word-from-Other-Application?p=966041#post966041
The real issue was (and still is to some extent) using reference libraries.