Can't you trap the error number of the failed .Add method?
Eddie
Philippe Mermoud - 24 Aug 2005 09:02 GMT
I'm not that expert in VBA. I know the trap mechanism but it exists in VBA ?
How can I use it ?
> Can't you trap the error number of the failed .Add method?
>
> Eddie
Jezebel - 24 Aug 2005 09:43 GMT
on error resume next
....
> I'm not that expert in VBA. I know the trap mechanism but it exists in VBA
> ?
[quoted text clipped - 3 lines]
>>
>> Eddie
Dim Flag As Boolean, prop As CustomProperty
Flag = False
For Each prop In ActiveDocument.CustomDocumentProperties
If prop.Name = "mycustomproperty" Then
Flag = True
End If
Next
If Flag = True Then
MsgBox "The Custom Property exists."
Else
MsgBox "The Custom Property does not exist."
End If

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> After having added a custom document property (using "Add") how can I know
> whether it is or not in my document ? If I call Add again it crashes down
> saying the property exists already.