使用OLE对WORD文档操作
现有一个WORD文档,文档中有两个表,请问怎样才能将数据写入到WORD文档已有的表的指定位置上?
AnsiString ReportFile;
try
{
Wd = Variant::CreateObject("Word.Application");
}
catch(...)
{
Application->MessageBox("Start Word Error","Error",MB_ICONSTOP|MB_OK);
return;
}
Wd.OlePropertySet("Visible",true);
Wd.OlePropertyGet("Documents").OleProcedure("Open","c:\\HighFeeReport.dot");
WDoc = Wd.OlePropertyGet("ActiveDocument");
WRange=WDoc.OleFunction("Range");
WTabs=WRange.OlePropertyGet("Tables");
WTab=WTabs.OlePropertyGet("Tables",1);//该语句调试不通过!!!!
WCell=WTab.OleFunction("cell",2,2);
CellRange=WCell.OlePropertyGet("Range");
CellRange.OlePropertySet("Text","Hello");