Solved

Text Object Model/RichEdit

Posted on 2000-03-22
2
283 Views
Last Modified: 2013-11-20
In the Platform SDK the Save method is defined as (defined in TOM.H)

STDMETHODIMP ITextDocument::Save(
  VARIANT *pVar,
  long Flags,
  long CodePage
);
Parameters pVar  [in] The save target. This parameter is a VARIANT, which can be a file name, an IStream, or null.

My question is: How the heck do I get an IStream in a VARIANT so ITextDocument::Save will save to my stream?
If I use a BSTR for file name it works fine.

Thanks,
Tony.

Here's my code:
      ITextDocument *pTextDoc;
      GetIRichEditOle()->QueryInterface(IID_ITextDocument, (void **) &pTextDoc);
      IMyTextDocument *pMyTextDoc = new IMyTextDocument(pTextDoc);
     
      IStream *pStream = NULL;
      CreateStreamOnHGlobal( NULL, TRUE, &pStream);

      VARIANT Var;
      VariantInit(&Var);
      Var.vt = VT_UNKNOWN; //BSTR okay
      Var.punkVal = pStream; //"C:\\Test.rtf" okay

      pMyTextDoc->Save(&Var, 0, 0);

0
Comment
Question by:Tony_Sebastian
2 Comments
 
LVL 1

Accepted Solution

by:
yarond earned 100 total points
ID: 2660282
Just a guess, but there are two things you might want to try.
1. try passing it as VT_DISPATCH using pdispVal.
2. try not allocating your IStream as HGlobal. Maybe there is some sort of a memory reallocation problems here. Unlikely, but might be worth a try.
0
 

Author Comment

by:Tony_Sebastian
ID: 2661162
I'm using streamin and streamout, I initially wanted to use TOM because I saw the HTML flag and thought it would convert the RTF to html, but it doesn't, you have to stream HTML in to use the flag.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to create frequencies of a variable from SAS dataset? 10 139
Turn a spreadsheet into a vba executable. 2 98
Hibernate methods 2 83
Problem to Office 1 45
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question