Вставка формулы в Word из C++ Builder
1 Неопределенный символ 'wdFieldEmpty',
2 Could not find a match for 'Fields::Add(WordRangePtr,undefined,OleVariant,OleVariant)';
Вообще программа должна создавать документ Word и вставлять в него объект MSEquation -дробь 1/2. Часть кода я взял на этом форуме, но полного листинга там не было.Что я сделал не так?
Код:
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#pragma link "Word_XP_srvr"
#include "ComObj.hpp"
TForm2 *Form2;
TWordApplication *WordApplication1;
TWordDocument * WordDocument1;
//---------------------------------------------------------------------------
_fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormCreate(TObject *Sender)
{
WordApplication1 = new TWordApplication(this);
WordApplication1->ConnectKind = ckNewInstance;
WordApplication1->AutoQuit = true;
WordDocument1 = new TWordDocument(this);
WordApplication1->Connect();
WordDocument1->ConnectTo(WordApplication1->Documents->Add());
WordApplication1->set_Visible(true);
TOleString txt("EQ x=\\f(1;2)");
WordDocument1->ActiveWindow->ActivePane->Selection->Fields->Add
(
WordDocument1->ActiveWindow->ActivePane->Selection->Range,
(OleVariant)wdFieldEmpty,
(OleVariant)txt,
(OleVariant)false
);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormDestroy(TObject *Sender)
{
WordApplication1->Free();
}
#pragma hdrstop
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
#pragma link "Word_XP_srvr"
#include "ComObj.hpp"
TForm2 *Form2;
TWordApplication *WordApplication1;
TWordDocument * WordDocument1;
//---------------------------------------------------------------------------
_fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormCreate(TObject *Sender)
{
WordApplication1 = new TWordApplication(this);
WordApplication1->ConnectKind = ckNewInstance;
WordApplication1->AutoQuit = true;
WordDocument1 = new TWordDocument(this);
WordApplication1->Connect();
WordDocument1->ConnectTo(WordApplication1->Documents->Add());
WordApplication1->set_Visible(true);
TOleString txt("EQ x=\\f(1;2)");
WordDocument1->ActiveWindow->ActivePane->Selection->Fields->Add
(
WordDocument1->ActiveWindow->ActivePane->Selection->Range,
(OleVariant)wdFieldEmpty,
(OleVariant)txt,
(OleVariant)false
);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormDestroy(TObject *Sender)
{
WordApplication1->Free();
}