Delete all enclosures


This tip demonstrates how to delete all enclosures from the metadata at once without altering the rest of the metadata content.

NOTE: this macro doesn't verify that the selected object supports metadata, whether it already has metadata, or whether the metadata is writable. For an example of how this is accomplished, look at the function HasWritableMD in the CheckMD module provided with the Metadata Spellchecker sample.

How to use:
Sub DeleteAllEnclosures()
    Dim pGxApp As IGxApplication
    Dim pGxView As IGxView
    Dim pMD As IMetadata
    Dim pXPS As IXmlPropertySet
    Dim pPS As IPropertySet
    Dim dNow As Date
    Set pGxApp = Application
    Set pMD = pGxApp.SelectedObject
    Set pXPS = pMD.Metadata
    ' delete regular and image enclosures in the metadata - 
    ' the last parameter must be true to delete all information 
    ' associated with the enclosure such as its description
    pXPS.DeletePropertyByAttribute "EsriPropertyType", "Base64", True
    pXPS.DeletePropertyByAttribute "EsriPropertyType", "Image", True
    ' set the time that the metadata was modified, then 
    ' save the changes
    Set pPS = pXPS
    dNow = Now
    pPS.SetProperty "Esri/ModDate", Format(dNow, "yyyymmdd")
    pPS.SetProperty "Esri/ModTime", Format(dNow, "HhNnSs") & "00"
    pMD.Metadata = pXPS
    Set pGxView = pGxApp.View
    If TypeOf pGxView Is IGxDocumentationView Then
    End If

End Sub