1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
void __fastcall TForm1::BookMark(AnsiString Cherche, AnsiString Texte)
{
Bookmark * b = NULL;
WordRange * r = NULL;
_DocumentPtr WordDF;
//On récupere le document actif (WordD est de type TWordApplication)
WordDF = WordD->get_ActiveDocument();
WideString vCherche = Cherche.c_str();
WideString vText = Texte.c_str();
Variant wC = vCherche;
//Si le signet existe bien dans le document
if (WordDF->Bookmarks->Exists(vCherche.c_bstr()))
{
//On récupere ce signet
b = WordDF->Bookmarks->Item(wC);
b->Select();
r = b->get_Range();
r->Select();
//On affecte le texte voulu au signet
r->set_Text(vText.c_bstr());
}
} |
Partager