网站首页  汉语字词  英语词汇  考试资料  写作素材

请输入您要查询的范文:

 

标题 获取word文档的作者和主题
分类 范文、应用文-IT技术专栏-办公软件使用
范文
    当然要先添加对word地组件地引用,添加命名空间地引用,代码:
    word.application oword;
    word._document odoc;
    object omissing = missing.value;
    object docbuiltinprops;
    object source = @docpath;
    object unknown =type.missing;
    oword = new word.application();
    try
    {
    odoc = oword.documents.open(ref source,ref unknown,
    ref unknown,ref unknown,ref unknown,
    ref unknown,ref unknown,ref unknown,
    ref unknown,ref unknown,ref unknown,
    ref unknown );
    docbuiltinprops = odoc.builtindocumentproperties;
    type typedocbuiltinprops = docbuiltinprops.gettype();
    //获取作者
    string index = author;
    string propsvalue;
    object docauthor = typedocbuiltinprops.invokemember(item,
    bindingflags.default |
    bindingflags.getproperty,
    null,docbuiltinprops,
    new object[] {index} );
    type typedocauthorprop = docauthor.gettype();
    propsvalue = typedocauthorprop.invokemember(value,
    bindingflags.default |
    bindingflags.getproperty,
    null,docauthor,
    new object[] {} ).tostring();
    messagebox.show( propsvalue,author );
    //获取主题
    index = subject;
    propsvalue = the subject;
    object docsubjectprop = typedocbuiltinprops.invokemember(item,
    bindingflags.default |
    bindingflags.getproperty,
    null,docbuiltinprops,
    new object[] {index} );
    type typedocsubjectprop = docsubjectprop.gettype();
    propsvalue = typedocsubjectprop.invokemember(value,
    bindingflags.default |bindingflags.getproperty,
    null,docsubjectprop,
    new object[] {} ).tostring();
    messagebox.show( propsvalue,subject );
    }
    finally
    {
    //关闭word进程
    object save = false;
    oword.quit(ref save,ref unknown,ref unknown);
    system.runtime.interopservices.marshal.releasecomobject(oword);
    }
随便看

 

客官网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cumcu.com All Rights Reserved
更新时间:2026/3/21 7:15:14