VC中对office的操作(2)
//设置视图
Window win = app.GetActiveWindow();
View view = win.GetView();
Pane ap = win.GetActivePane();
if(view.GetSplitSpecial() == 0)
...{
view.SetType(1);
}
else
...{
view.SetType(1);
}
/**//////绘制标格/////////////////////////////////////////////////////////////////////
_Document doc = app.GetActiveDocument();
Selection sel = app.GetSelection();
//写表名
_Font font = sel.GetFont();
float fs = font.GetSize();
Paragraphs pg = sel.GetParagraphFormat();
long ali = pg.GetAlignment();
font.SetSize(16);
pg.SetAlignment(1);
sel.TypeText(tablename);
sel.TypeParagraph();
font.SetSize(fs);
pg.SetAlignment(ali);
Tables tables = doc.GetTables();
Range range = sel.GetRange();
//CComVariant v1((short)1);
//CComVariant v2((short)1);
CComVariant v1((short)1);
CComVariant v2((short)1);
tables.Add(range,rowNum,colNum,&v1,&v2);
/**////填写标格///////////////////////////////////////////////////////////////////////
if(tablestr.GetSize() <= 1)
...{
AfxMessageBox("绘制标格时出错!");
doc.ReleaseDispatch();
docs.ReleaseDispatch();
win.ReleaseDispatch();
view.ReleaseDispatch();
ap.ReleaseDispatch();
sel.ReleaseDispatch();
font.ReleaseDispatch();
CComVariant SaveChanges(false),OriginalFormat,RouteDocument;
app.Quit(&SaveChanges,&OriginalFormat,&RouteDocument);
app.ReleaseDispatch();
return;
}
- 上一篇:VC中的常用的20个方法
- 下一篇:VC6.0编写C/S消息传送程序