I very new at this and I'm sure this is a very stupid question. The
following is the function I copied from the Microsoft website. How do I get
this to run in word 2000.
Thanks so much for the help.
Function AddCustomDocumentProperty(EffectiveDate As String, _
Text As Long, _
Optional varPropValue As Variant = "", _
Optional blnLinkToContent As Boolean = False, _
Optional varLinkSource As Variant = "") _
As Long
Dim prpDocProp As DocumentProperty
varPropValue = "03/01/06"
If blnLinkToContent = False And Len(varPropValue) = 0 Then
AddCustomDocumentProperty = ERR_CUSTOM_LINKTOCONTENT_VALUE
Exit Function
ElseIf blnLinkToContent = True And Len(varLinkSource) = 0 Then
AddCustomDocumentProperty = ERR_CUSTOM_LINKTOCONTENT_LINKSOURCE
Exit Function
ElseIf lngPropType < msoPropertyTypeNumber Or _
lngPropType > msoPropertyTypeFloat Then
AddCustomDocumentProperty = ERR_CUSTOM_INVALID_DATATYPE
Exit Function
ElseIf Len(EffectiveDate) = 0 Then
AddCustomProperty = ERR_CUSTOM_INVALID_PROPNAME
Exit Function
End If
Call DeleteIfExisting("Effective Date")
Select Case blnLinkToContent
Case True
Set proDocProp = ActiveWorkBook.CustomDocumentProperties _
.Add(Name:=EffectiveDate, LinkToContent:=blnLinkToContent, _
Type:=Text, LinkSource:=varLinkSource)
ActiveWorkBook.Save
Case False
Set proDocProp = ActiveWorkBook.CustomDocumentProperties. _
Add(Name:=EffectiveDate, LinkToContent:=blnLinkToContent, _
Type:=Text, Value:=varPropValue)
End Select
End Function
> Yes, you can.
>
[quoted text clipped - 14 lines]
> >
> > MH
Alright, I changed your code just a little, I commented out the Call
DeleteIfExisting, because you did not include that function, and I
changed ActiveWorkbook, to ActiveDocument since we are working inside
of Word. Also, I could tell that you were attempting to modify the
function to get the values into the function, I changed that back.
When you call functions which have values, you have to provide the
information into the function. For instance, in the function you
provided, each of the values requested by the function are listed
between the parens. The function also tells you what type of value it
is expecting. For instance the strPropName as String tells you that
you should provide a name and since it is a string value, you should
enclose the name in quotes.
Sub addCustomProp()
'This can be run from the Macros window.
Call AddCustomDocumentProperty("CustomDate", msoPropertyTypeDate,
"02/28/06", False, False)
End Sub
The hard part that you have is that you will have to know what your
valid msoProperty types are. They are limited:
msoPropertyTypeNumber - used for numbers, not decimal
msoPropertyTypeString - used for text
msoPropertyTypeDate - used for dates
msoPropertyTypeBoolean - used for true / false, yes/no
msoPropertyTypeFloat - used for decimal numbers or extremely large
numbers, I can't think of a reason to use this property type.
Function AddCustomDocumentProperty(strPropName As String, _
lngPropType As Long, _
Optional varPropValue As Variant =
"", _
Optional blnLinkToContent As Boolean
= False, _
Optional varLinkSource As Variant =
"") _
As Long
' This procedure adds the custom property specified in the
strPropName
' argument. If the blnLinkToContent argument is True, the custom
' property is linked to the location specified by varLinkSource.
' The procedure first checks for missing or inconsistent input
parameters.
' For example, a value must be provided unless the property is
linked, and
' when you are using linked properties, the source of the link must
be provided.
Dim prpDocProp As DocumentProperty
' Validate data supplied in arguments to this procedure.
If blnLinkToContent = False And Len(varPropValue) = 0 Then
' No value supplied for custom property.
AddCustomDocumentProperty = ERR_CUSTOM_LINKTOCONTENT_VALUE
Exit Function
ElseIf blnLinkToContent = True And Len(varLinkSource) = 0 Then
' No source provided for LinkToContent scenario.
AddCustomDocumentProperty = ERR_CUSTOM_LINKTOCONTENT_LINKSOURCE
Exit Function
ElseIf lngPropType < msoPropertyTypeNumber Or _
lngPropType > msoPropertyTypeFloat Then
' Invalid value for data type specifier. Must be one of the
' msoDocProperties enumerated constants.
AddCustomDocumentProperty = ERR_CUSTOM_INVALID_DATATYPE
Exit Function
ElseIf Len(strPropName) = 0 Then
' No name supplied for new custom property.
AddCustomDocumentProperty = ERR_CUSTOM_INVALID_PROPNAME
Exit Function
End If
' Call DeleteIfExisting(strPropName)
Select Case blnLinkToContent
Case True
Set prpDocProp = ActiveDocument.CustomDocumentProperties _
.add(Name:=strPropName, LinkToContent:=blnLinkToContent, _
Type:=lngPropType, LinkSource:=varLinkSource)
ActiveWorkbook.Save
Case False
Set prpDocProp = ActiveDocument.CustomDocumentProperties. _
add(Name:=strPropName, LinkToContent:=blnLinkToContent, _
Type:=lngPropType, Value:=varPropValue)
End Select
End Function
To call it and provide the name of the property, the type of the
property, the value of the property and whether the property is linked
to content:
Sub addCustomProp()
'This can be run from the Macros window.
Call AddCustomDocumentProperty("CustomDate", msoPropertyTypeDate,
"02/28/06", False)
End Sub
The hard part that you have is that you will have to know what your
valid msoProperty types are. They are limited:
msoPropertyTypeNumber - used for simple numbers, not decimal
msoPropertyTypeString - used for text
msoPropertyTypeDate - used for dates
msoPropertyTypeBoolean - used for true / false, yes/no
msoPropertyTypeFloat - used for decimal numbers or extremely large
numbers, I can't think of a reason to use this property type.

Signature
Dawn Crosier
Microsoft MVP
"Education Lasts a Lifetime"
This message is posted to a newsgroup. Please post replies and
questions to the newsgroup so that others can learn as well.
Mickey - 01 Mar 2006 15:20 GMT
Thank you so much. It worked great. What do I need to do now to include the
"Call DeletefExisting()" function since all of the documents will have a date
already in them. Also, how can I get the date to print as XX/XX/XX.
Once again thanks so much.
Mickey
> Alright, I changed your code just a little, I commented out the Call
> DeleteIfExisting, because you did not include that function, and I
[quoted text clipped - 112 lines]
> msoPropertyTypeFloat - used for decimal numbers or extremely large
> numbers, I can't think of a reason to use this property type.
Dawn Crosier - 01 Mar 2006 23:00 GMT
Sub DeleteIfExisting(strPropName As String)
ActiveDocument.CustomDocumentProperties(strPropName).Delete
End Sub
Should do it for you.
As far as I know, there is not a method to make the date show as
mm/dd/yy. There may be a registry setting which will do it.

Signature
Dawn Crosier
Microsoft MVP
"Education Lasts a Lifetime"
This message is posted to a newsgroup. Please post replies and
questions to the newsgroup so that others can learn as well.
> Thank you so much. It worked great. What do I need to do now to
> include the
[quoted text clipped - 5 lines]
>
> Mickey