Page 1 of 1

[How to] How to save OLE objects in RTF

Posted: Thu Sep 15, 2005 4:59 pm
by Sergey Tkachenko
Saving TOLEContainers from TRichView to RTF file:
http://www.trichview.com/forums/viewtopic.php?t=108

Posted: Tue Sep 29, 2009 9:16 am
by Sergey Tkachenko
I created a unit based on the code from the topic above.
http://www.trichview.com/support/files/ ... rtortf.zip

It contains the function

Code: Select all

function GetOleContainerRTFString(OleContainer: TOleContainer;
  Image: TMetafile = nil): String;
This function returns RTF representation of OleContainer for assigning to OutStr parameter of TRichView.OnSaveComponentToFile event:

Code: Select all

procedure TForm1.RichViewEdit1SaveComponentToFile(Sender: TCustomRichView;
  Path: String; SaveMe: TPersistent; SaveFormat: TRVSaveFormat;
  var OutStr: TRVUnicodeString);
begin
  case SaveFormat of
   ...
   rvsfRTF:
      begin
        if SaveMe is TOleContainer then
          OutStr := GetOleContainerRTFString(TOleContainer(SaveMe))
        ...
      end;
  end;
end;
The second parameter (Image) is optional. If assigned, this metafile will be used as an image representing this OleContainer. If not assigned, the function makes this image itself.

Update:
2018-Apr-20: for compatibility with TRichView 17.3 (for older versions, change the type of OutStr parameter to String

Posted: Mon Mar 09, 2015 3:05 am
by gary
Is there a same function for export ole to html?

Posted: Tue Mar 10, 2015 3:54 pm
by Sergey Tkachenko
I am not sure if it is possible at all.
HTML can include ActiveX controls, not OLE.

ActiveX is a programming code, while OLE object is data (such as a picture).