Jump to content
Software FX Community

Export chart to stream - PLEASE HELP

User (Legacy)

Recommended Posts


I have been trying unsuccessfully to export a chart to a stream (I'm using

Delphi 5). I found the newsgroup message that has a C example of how to do


variant v;

v_vt(&v) = VT_STREAM;

V_UNKNOWN(&v) = pStream (points to a valid IStream).

I have ported this code to Delphi, and I receive the ole error "invalid

variant operation".

After some research, I found in the Win32 Developer's Help reference that a

VT_STREAM is not a valid type indicator for a variant (see below):

******* From the Win32 Developer's Help for "Type Indicators"


The following table lists the standard OLE-defined property type indicators

and their meaning:

VT_STREAM 66 A VT_LPSTR (DWORD count of bytes followed by a zero-terminated

string that many bytes long) that names the stream containing the data. The

real value for this property is stored in a stream object, which is a

sibling to the Contents stream. This type is only valid for property sets

stored in the Contents stream of a storage object.


Is there another type indicator that the Export method may accept? I have

tried using VT_UNKNOWN, and I don't get the ole error, but the export fails

(returns a very long negative number: -2187......). How is the export

working in ANY language if the Help statement is true?

Here is the Delphi port code, any help is greatly appreciated. I have tried

many different variations of this code (using variant, Olevariant, casting

the streamadapter as IUnKnown, etc.):

procedure TForm1.btnExportClick(Sender: TObject);


vData: oleVariant;

tmpReturn : OleVariant;

AStream : TStreamAdapter;

MStream : TMemoryStream;


MStream := TMemoryStream.Create;

AStream := TStreamAdapter.Create(MStream); // tstreamadapter is

Delphi's wrapper that implements IStream

TVarData(vData).vtype := VT_STREAM;

TVarData(vData).vpointer := Pointer(AStream as IStream);

tmpReturn:= caChart.Export(CHART_CFXOLEFILE, vData);


Thanks in advance,


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...