Asp.net

Source: Internet
Author: User


'Read custom attributes

The code is as follows: Copy code

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 () {"remarks "})
ResultString = Authorprop. GetType. InvokeMember ("Value", Reflection. BindingFlags. Default Or Reflection. BindingFlags. GetProperty, Nothing, Authorprop, New Object (){})

Catch ex As Exception

End Try
'Write
Dim Authorprop = PropertyType. InvokeMember ("Item", Reflection. BindingFlags. Default Or Reflection. BindingFlags. SetProperty, Nothing, properties, New Object () {"remarks", ResultString })


Another method


'Add new property

The code is as follows: Copy code
SourceDoc. CustomDocumentProperties. Add (Name: = "PropertyName", LinkToContent: = False, Type: = Microsoft. Office. Core. MsoDocProperties. msoPropertyTypeString, Value: = "PropertyValue ")

'Modify attributes

The code is as follows: Copy code

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

'Get the property value

The code is as follows: Copy code
PropertyValue = SourceDoc. CustomDocumentProperties ("PropertyName"). Value

After reading the write operation, you can right-click the word document and choose Properties to view the effect. However, when the word document is open, right-click the document and there is no "custom" or "abstract" Tab.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.