Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / February 2004

Tip: Looking for answers? Try searching our database.

update document property from code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sandeep - 05 Feb 2004 14:50 GMT
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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.