源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

VB.net读取Word文档属性的方法

  • 时间:2020-03-20 06:09 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:VB.net读取Word文档属性的方法
[u]复制代码[/u] 代码如下:
'对自定义属性进行读取          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})
另一种写法:
[u]复制代码[/u] 代码如下:
'增加新属性 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
[u]复制代码[/u] 代码如下:
'读取内置属性,以备注为例  ResultString= SourceDoc.BuiltInDocumentProperties(Microsoft.Office.Interop.Word.WdBuiltInProperty.wdPropertyComments).value
读取写入操作后可以通过在Word文档上右键->属性查看效果,但当Word文档处于打开状态时,文档上右键是没有“自定义”和“摘要”这两个Tab的。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部