Board index » cppbuilder » Opening Word Document
Ronald Phillips
![]() CBuilder Developer |
Opening Word Document2004-03-03 01:28:13 AM cppbuilder4 Hi I've just started to look at the COM server objects in C++ Builder 5 Professional. I found some sample code in the help file, but I've had to modify it to even get it to compile. For now, I'd just like to open a Word document by clicking on a button. I've placed a button and WordApplication on a form, and have come up with the following code - don't laugh - I'm new to all this: #include <vcl.h> #pragma hdrstop #include "Unit1.h" //-------------------------------------------------------------------------- - #pragma package(smart_init) #pragma link "Word_2K_SRVR" #pragma resource "*.dfm" TForm1 *Form1; //-------------------------------------------------------------------------- - __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //-------------------------------------------------------------------------- - void __fastcall TForm1::Button1Click(TObject *Sender) { String filename = "C:\\test.doc"; Variant FileName = filename.c_str(); WordApplication1->Documents->Open(FileName, TNoParam(), TNoParam(), TNoParam(), TNoParam(), TNoParam(), TNoParam(), TNoParam(), TNoParam(), TNoParam(), TNoParam(), TNoParam() ); } When I run it, I get an error message 'this->Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format, Encoding, Visible, (Word_2k::WordDocumentPtr*)&prop)':Bad variable type. @ c:\.....\VCL\Word_2k.h/7034 I've looked at the Word2_k.h file, and I think I have the correct number of parameters, etc. However, I don't really understand TVariant and TNoParam(). I'd really appreciate some help with this. Thanks in advance David |