会考成绩查询-86考网
首页 范文 > IT技术专栏 > 办公软件使用 >

获取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.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技术专栏

阅读全文
标签: 没有tag

上一篇:怎么建立良好网络口碑?口碑营销技巧

下一篇:word使用操作技巧:再议删除编号

相关推荐
猜你喜欢
本类最新