Topic
  • 2 replies
  • Latest Post - ‏2013-05-13T18:22:10Z by llandale
llandale
llandale
3035 Posts

Pinned topic OLE Insert Rich Text

‏2013-05-11T20:41:56Z |

I'm not very good with this OLE stuff.  Can I paste rich text directly into an MS-Word cell?

I've got a OleAutoObj handle on the 'Range' of the 'Cell', but when I 'InsertAfter' I get the rich text tags instead of the rich text.  'InsertAfter' for raw text is working.

  • string Text = richTextWithOle(oCurr."Object Text")
    clear(oaaArgs)
    put(oaaArgs, "Text", Text)
    oleMethod(oaoRange, "InsertAfter", oaaArgs)

Table cell looks like:

  • {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Tahoma ...

Do I have to copy-paste via the clipboard?  Extract functions from "word.dxl"?  That looks like this (which is working), but I don't want to use the clipboard:

  • setRichClip(richText(Text))
    oleMethod(oaoRange, "Paste")

-Louie

  • Adamarla
    Adamarla
    79 Posts

    Re: OLE Insert Rich Text

    ‏2013-05-13T05:11:08Z  

    Unfortunatly, Word only auto converts richtext from either the clipboard or from an .rtf file. So your options for automation are copy/paste which hogs the clipboard, or writing  thousands of small files which thrashes the disk.

  • llandale
    llandale
    3035 Posts

    Re: OLE Insert Rich Text

    ‏2013-05-13T18:22:10Z  
    • Adamarla
    • ‏2013-05-13T05:11:08Z

    Unfortunatly, Word only auto converts richtext from either the clipboard or from an .rtf file. So your options for automation are copy/paste which hogs the clipboard, or writing  thousands of small files which thrashes the disk.

    Then is the following reasonable:

    • create an RTF file (using a Stream) with the contents I want
      •  Some header indicating the start/end of the table and how many columns there are supposed to be
      • the content of cells are separated by some special string of characters
    • With OLE, invoke a new Word instance and command it to open the RTF
    • Set 'Selection' using the special 'table' characters to select the entire table
    • Convert to Table, specifying the number of columns and using the special string of characters as the delimiters

    This I think will require me to resolve the VBA issue of DefaultTableSeparator; which appears to be a string not a char.

    -Louie