在vc中怎么样在word中写入东西? 在vc中怎么样在word中写入东西?(比如access表中的数据,按照行列写到word中)谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个简单打开doc文件,按它的格式写就可以了 不行,我以为是rtf格式…… //automation word void CReportDemoDlg::OnStartword() { Table table; Tables tables; if (!WordApp.CreateDispatch("Word.Application",NULL)) { AfxMessageBox("创建MS-WORD服务失败!"); exit(1); } ; WordApp.SetVisible(true); docs=WordApp.GetDocuments(); COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR); COleVariant start_line,end_line; COleVariant Dot("c:\\test.dot"); //使用test.dot作为模板建立新文档 doc=docs.Add(&Dot,&covOptional); //获得DOC文档的书签集 boots=doc.GetBooks(); //第一到三列的的书签名分别是rol1、rol2、rol3 COleVariant tem1("rol1"); boot=boots.Item(&tem1); range=boot.GetRange(); //设置列标题 range.SetText("列标题1"); COleVariant tem2("rol2"); boot=boots.Item(&tem2); range=boot.GetRange(); range.SetText("列标题2"); COleVariant tem3("rol3"); boot=boots.Item(&tem3); range=boot.GetRange(); range.SetText("列标题3"); //设置报表报送时间 COleVariant tem4("time"); boot=boots.Item(&tem4); range=boot.GetRange(); range.SetText("2002年1月1日"); //设置单元格内容 tables=doc.GetTables(); table=tables.Item(1); Cell cell; for(int i=2;i<=9;i++) { for(int ii=1;ii<=3;ii++) { cell=table.Cell(i,ii); range=cell.GetRange(); range.SetText("????"); } }} 各位大神,关于窗口重叠的问题。 新手问两个文本框的问题! 请问如何可以获得一个VC项目或Windows EXE程序占用的全局变量的清单 如何将class封装成dll? 求教:512色的位图如何存储? 请问:使用VPN在广域网上联接的两个局域网之间,能不能用UDP协议通讯? 怎样用vc取出word文档中的图像,取出图像的格式是位图吗? 用CSocket发送网络数据延时问题? 使用ADO编程时怎么样绑定数据 ===>>“关于C++程序设计”(钱能 主编)的评价!!! 关于这个文件desktop.ini 关于 list control 文字显示问题?
打开doc文件,按它的格式写就可以了
void CReportDemoDlg::OnStartword()
{
Table table;
Tables tables;
if (!WordApp.CreateDispatch("Word.Application",NULL))
{
AfxMessageBox("创建MS-WORD服务失败!");
exit(1);
} ;
WordApp.SetVisible(true);
docs=WordApp.GetDocuments();
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
COleVariant start_line,end_line;
COleVariant Dot("c:\\test.dot");
//使用test.dot作为模板建立新文档
doc=docs.Add(&Dot,&covOptional);
//获得DOC文档的书签集
boots=doc.GetBooks();
//第一到三列的的书签名分别是rol1、rol2、rol3
COleVariant tem1("rol1");
boot=boots.Item(&tem1);
range=boot.GetRange();
//设置列标题
range.SetText("列标题1");
COleVariant tem2("rol2");
boot=boots.Item(&tem2);
range=boot.GetRange();
range.SetText("列标题2");
COleVariant tem3("rol3");
boot=boots.Item(&tem3);
range=boot.GetRange();
range.SetText("列标题3");
//设置报表报送时间
COleVariant tem4("time");
boot=boots.Item(&tem4);
range=boot.GetRange();
range.SetText("2002年1月1日");
//设置单元格内容
tables=doc.GetTables();
table=tables.Item(1);
Cell cell;
for(int i=2;i<=9;i++)
{
for(int ii=1;ii<=3;ii++)
{
cell=table.Cell(i,ii);
range=cell.GetRange();
range.SetText("????");
}
}
}