How to clear all built-in document properties?

A

avkokin

Hello.
I wonder if there is a way to clear all built-in document properties?
And not for one document but for many into one the folder.
If I will use next code (as example for active document) then I get
the error:
Dim oProp As DocumentProperty
For Each oProp In ActiveDocument.BuiltInDocumentProperties
oProp.Delete
Next
Thank you very much.
 
F

fumei via OfficeKB.com

"the error"???? WHAT error? I am guessing you got a Type 13 mis-match error,
or an "Application or object defined error".

1. do not use .Delete
2. BuiltInDocumentProperties is an ENUM, and has items that are not present
in all Office applications. Therefore, use an On Error Resume Next when
iterating through it.
3. if you wish to "clear" the values, then do that.

Like this:

Sub ClearDocProps()
Dim oProp As DocumentProperty
On Error Resume Next
For Each oProp In ActiveDocument.BuiltInDocumentProperties
oProp.Value = ""
Next
End Sub
 

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