手机
当前位置:查字典教程网 >编程开发 >vb.net >VB.net读取Word文档属性的方法
VB.net读取Word文档属性的方法
摘要:复制代码代码如下:'对自定义属性进行读取DimProperties=SourceDoc.CustomDocumentPropertiesDi...

复制代码 代码如下:

'对自定义属性进行读取

Dim Properties = SourceDoc.CustomDocumentProperties

Dim PropertyType As Type = Properties.GetType

Try

Dim Authorprop = PropertyType.InvokeMember("Item", Reflection.BindingFlags.Default Or Reflection.BindingFlags.GetProperty, Nothing, Properties, New Object() {"备注"})

ResultString = Authorprop.GetType.InvokeMember("Value", Reflection.BindingFlags.Default Or Reflection.BindingFlags.GetProperty, Nothing, Authorprop, New Object() {})

Catch ex As Exception

End Try

'写入

Dim Authorprop = PropertyType.InvokeMember("Item", Reflection.BindingFlags.Default Or Reflection.BindingFlags.SetProperty, Nothing, properties, New Object() {"备注", ResultString})

另一种写法:

复制代码 代码如下:

'增加新属性

SourceDoc.CustomDocumentProperties.Add(Name := "PropertyName", LinkToContent := False, Type := Microsoft.Office.Core.MsoDocProperties.msoPropertyTypeString, Value := "PropertyValue")

'修改属性

SourceDoc.CustomDocumentProperties("PropertyName").Value = PropertyValue

'获取属性值

PropertyValue =SourceDoc.CustomDocumentProperties("PropertyName").Value

复制代码 代码如下:

'读取内置属性,以备注为例

ResultString= SourceDoc.BuiltInDocumentProperties(Microsoft.Office.Interop.Word.WdBuiltInProperty.wdPropertyComments).value

读取写入操作后可以通过在Word文档上右键->属性查看效果,但当Word文档处于打开状态时,文档上右键是没有“自定义”和“摘要”这两个Tab的。

【VB.net读取Word文档属性的方法】相关文章:

设置Win8系统“家庭安全”的方法

iPhone如何查询序列号判断是否是新机

Win8.1直接进系统不用输密码登录的方法

VB.NET获取文件默认图标的方法

iPhone6支付宝指纹支付使用方法

iPhone6 App Store快速刷新方法

创建yy子频道的方法

vb.net验证密码是否复杂的方法

iPhone苹果手机信号图标变数字显示方法

iphone6 plus输入法设置方法

精品推荐
分类导航