Link to home
Start Free TrialLog in
Avatar of craig20120
craig20120

asked on

In a C++ Word Plugin how to create a blank RTF document?

I am using C++ MFC / ATL in a Word 2003 plugin and need to know how to create a new Word document using the RTF document type.  Cuurently, I am doing the following to create a blank Word doc.

MSWord::_DocumentPtr pdoc = NULL;
pdoc = m_spApp->Documents->Add(&Opt, (&Opt, (&Opt, COleVariant((short)true));

The third argument is the Document type, but how do I specify this to be RTF.  
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Don't you specify the document type when saving, not when creating a new document?
Avatar of craig20120
craig20120

ASKER

Syntax correction below... Sorry cut and pasted the arguments.

MSWord::_DocumentPtr pdoc = NULL;
pdoc = m_spApp->Documents->Add(&Opt, &Opt, &Opt, COleVariant((short)true));

To Answer the above question. I'm not sure.  After doing some more research, I found the following on MSDN.

DocumentType  Optional Variant. Can be one of the following WdNewDocumentType constants: wdNewBlankDocument, wdNewEmailMessage, wdNewFrameset, or wdNewWebPage. The default constant is wdNewBlankDocument.

I had thought that RTF was one of the document types.  

So plan B...   How can I create an RTF document to be copied to the clipboard Without first saving the doc as RTF??
I think for a new document there isn't any rtf specifier.  That is with the SaveAs...

There shouldn't be anything to stop you saving to a temporary file as an rtf first, you can always delete it afterwards.
I really want to avoid writing it out first.  These documents could be huge.  Does anyone know of a way to create an RTF doc in Word without saving first???

ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial