add custom properties for office 2000

J

John

I am trying to add custom properties to office 2000 documents programmatically. I have found the office 9.0 object library and the documentproperties object, but it doesn't seem to work with the msdn code sample.
 
J

Jonathan West

John said:
I am trying to add custom properties to office 2000 documents
programmatically. I have found the office 9.0 object library and the
documentproperties object, but it doesn't seem to work with the msdn code
sample.

If you want to add a custom document property, use code like this

ActiveDocument.CustomDocumentProperties.Add Name:="Myprop", _
Type:=msoPropertyTypeString, Value:="My property value"
 
J

John

I am not using VBA. I need this to work for any office document and from a separate windows app. The idea is to select 30 word documents and add the custom properties to all the files. I have been most successful with the following code..

Dim oWordApp As New Word.Application(
Dim oWordDoc As New Word.Document(
Dim oProps As Objec

oWordDoc = oWordApp.Documents.Open("c:\test.doc", , , , , , , , , , , False
oProps = oWordDoc.ActiveWindow.Document.CustomDocumentPropertie

oProps.Add("Test", False, msoPropertyTypeString, "Test"

'MsgBox(oWordDoc.Name & " is opened"

oWordDoc.Save(
oWordDoc.ActiveWindow.Close(

The add method does not work properly. I don't know what value to assign to the msoPropertyString constant.
 
J

Jonathan West

John said:
I am not using VBA. I need this to work for any office document and from
a separate windows app. The idea is to select 30 word documents and add the
custom properties to all the files.

In that case, by far the quickest approach is to use dsofile.dll.

Dsofile.exe Lets You Edit Office Document Properties from Visual Basic and
ASP
http://support.microsoft.com/?kbid=224351

That article provides a link to a free download of dsofile.dll, and a sample
VB project that makes use of it.
 
C

Chad DeMeyer

msoPropertyTypeString = 4
i.e.,
oProps.Add "Test", 0, 4, "Test"

Regards,
Chad


John said:
I am not using VBA. I need this to work for any office document and from
a separate windows app. The idea is to select 30 word documents and add the
custom properties to all the files. I have been most successful with the
following code...
Dim oWordApp As New Word.Application()
Dim oWordDoc As New Word.Document()
Dim oProps As Object

oWordDoc = oWordApp.Documents.Open("c:\test.doc", , , , , , , , , , , False)
oProps = oWordDoc.ActiveWindow.Document.CustomDocumentProperties

oProps.Add("Test", False, msoPropertyTypeString, "Test")

'MsgBox(oWordDoc.Name & " is opened")

oWordDoc.Save()
oWordDoc.ActiveWindow.Close()

The add method does not work properly. I don't know what value to assign
to the msoPropertyString constant.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top