void __fastcall TForm1::btn1Click(TObject *Sender)
{ Variant WordApp,WordDocs,WordDoc;
Variant word_activedoc;
Variant word_select;
Variant word_table;
Variant my_cell; //创建Word对象:
WordApp=CreateOleObject("Word.Application");
WordDocs=WordApp.OlePropertyGet("Documents");
//打开Word文档:
WordDoc=WordDocs.OleFunction("Open","c:\\test.doc");
WordApp.OlePropertySet("Visible",true);
WordDoc = WordApp.OlePropertyGet("Documents");
word_activedoc = WordApp.OlePropertyGet("ActiveDocument");
//修改表格: Cell 行,列
word_table = word_activedoc.OlePropertyGet("Tables").OleFunction("Item", );
my_cell = word_table.OleFunction("Cell", (Variant), (Variant));
my_cell.OlePropertySet("Range", "11)");
my_cell = word_table.OleFunction("Cell", (Variant), (Variant));
my_cell.OlePropertySet("Range", "21)");
my_cell = word_table.OleFunction("Cell", (Variant), (Variant));
my_cell.OlePropertySet("Range", "22)");
//保存修改内容:
word_activedoc.OleProcedure("Save");
//打印文档:
WordApp.OlePropertyGet("ActiveDocument").OleFunction("PrintOut");
WordApp.OleProcedure("Quit"); }