龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VC开发 >

VC中对office的操作(2)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
//设置视图 Window win = app.GetActiveWindow(); View view = win.GetView(); Pane ap = win.GetActivePane(); if(view.GetSplitSpecial() == 0) ...{ view.SetType(1); } else ...{ view.SetType(1); } /**///

    //设置视图
    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;
    }

精彩图集

赞助商链接