Hi,
I am working with word 2000 using c# in which i am using
Word's exposed funtions.
Now from my c# code, how can I access all custom
properties and update them.
I can, however, update the fields used inside the document
using
document.field.Result.Text = "New Value"
but not been able to update the properties of the document.
document.CustomDocumentProperties return me an object. I
dont know, how to work with this object further to get and
update the custom properties.
Pls help.
Thx.
Sandeep
Peter Jamieson - 05 Feb 2004 19:06 GMT
I don't know about the C# syntax, but in VBA you can use e.g.
Dim oDP As DocumentProperty
Dim oDPs As DocumentProperties
With ActiveDocument
On Error Resume Next
' list Custom property names and values (careful, you may need
' properties with diferent types differently
Set oDPs = .CustomDocumentProperties
For Each oDP In oDPs
Debug.Print oDP.Name, oDP.Value
Next
' Insert a new DP called x
' Delete any old one
oDPs("x").Delete
Err.Clear
On Error GoTo 0
' Create the new one
Set dp = .CustomDocumentProperties.Add( _
Name:="x", _
LinkToContent:=False, _
Value:="a", _
Type:=msoPropertyTypeString)
' change its value
dp.Value = "b"
...and so on.
--
Peter Jamieson - Word MVP
Word MVP web site http://word.mvps.org/
> Hi,
>
[quoted text clipped - 15 lines]
> Thx.
> Sandeep