亚洲欧洲国产欧美一区精品,激情五月亚洲色五月,最新精品国偷自产在线婷婷,欧美婷婷丁香五月天社区

      考試首頁 | 考試用書 | 培訓(xùn)課程 | 模擬考場 | 考試論壇  
        當(dāng)前位置:編程開發(fā) > DotNET > VB.Net > 文章內(nèi)容
        

      VB.net讀取Word文檔屬性的方法

       [ 2017年7月5日 ] 【

        代碼如下:

        '對自定義屬性進(jìn)行讀取

        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})

        另一種寫法:

        復(fù)制代碼 代碼如下:

        '增加新屬性

        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

        復(fù)制代碼 代碼如下:

        '讀取內(nèi)置屬性,以備注為例

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

        讀取寫入操作后可以通過在Word文檔上右鍵->屬性查看效果,但當(dāng)Word文檔處于打開狀態(tài)時,文檔上右鍵是沒有“自定義”和“摘要”這兩個Tab的。

      將考試網(wǎng)添加到收藏夾 | 每次上網(wǎng)自動訪問考試網(wǎng) | 復(fù)制本頁地址,傳給QQ/MSN上的好友 | 申請鏈接 | 意見留言 TOP
      關(guān)于本站  網(wǎng)站聲明  廣告服務(wù)  聯(lián)系方式  站內(nèi)導(dǎo)航  考試論壇
      Copyright © 2007-2013 中華考試網(wǎng)(Examw.com) All Rights Reserved