Copy codeThe Code is as follows: 'read Custom Attributes
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:
Copy codeThe Code is as follows: 'Add a new property
SourceDoc. CustomDocumentProperties. Add (Name: = "PropertyName", LinkToContent: = False, Type: = Microsoft. Office. Core. MsoDocProperties. msoPropertyTypeString, Value: = "PropertyValue ")
'Modify attributes
SourceDoc. CustomDocumentProperties ("PropertyName"). Value = PropertyValue
'Get the property value
PropertyValue = SourceDoc. CustomDocumentProperties ("PropertyName"). Value
Copy codeThe Code is as follows: 'read the built-in attributes. Take the remarks as an example.
ResultString = SourceDoc. BuiltInDocumentProperties (Microsoft. Office. Interop. Word. WdBuiltInProperty. wdPropertyComments). 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.