86考网
会考成绩查询

获取word文档的作者和主题

作者:86考网 发布时间:2015-09-12 09:29:38 [手机版]
摘要:当然要先添加对word地组件地引用,添加命名空间地引用,代码: word.application oword; word._document odoc; object omissing = missing.value; object docbuiltinprops; object source = @docpath; object unknown =type.missing; oword = new word.app

当然要先添加对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);

}

更多信息请查看IT技术专栏


标签: 获取 word 文档 作者 主题
相关推荐
86考网声明:
(一) 由于各方面情况的调整与变化,本网所提供的考试信息仅供参考,敬请以权威部门公布的正式信息为准。
(二) 本网注明来源为其他媒体的稿件均为转载稿,免费转载出于非商业性学习目的,版权归原作者所有。如有内容、版权等问题请在30日内与本网联系。联系方式:邮件 jiansou123#126.com
最近更新
网站地图 | XML地图 | 手机版 | 标签
版权所有 © 2005-2022 www.kaoshi86.com 会考成绩查询 All Rights Reserved
本网站所有信息全是来源于互联网,如有侵权请来电咨询! 粤ICP备15072123号