Voici comment inserer un tableau Excel dans un document Word en utilisant Ole
le code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
void __fastcall TForm1::Button4Click(TObject *Sender)
{
Variant Connection, PasswordDocument, PasswordTemplate, WritePasswordDocument, WritePasswordTemplate, From, To;
Connection = "";
String SQLStatement = "SELECT Nom, Prenom, Age FROM [Feuil1$] WHERE ((Nom IS NOT NULL ) AND (Prenom IS NOT NULL ) AND (Age IS NOT NULL ))";
PasswordDocument = "";
PasswordTemplate = "";
WritePasswordDocument = "";
WritePasswordTemplate = "";
String DataSource = "C:\\tableau.xls";
From = -1;
To = -1;
vMSWord.OlePropertyGet("Selection").OlePropertyGet("Range").OleProcedure("InsertDatabase", 0, 0, false, Connection, SQLStatement.c_str(), PasswordDocument, PasswordTemplate, WritePasswordDocument, WritePasswordTemplate, DataSource.c_str()), From, To, true;
}